repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
0k/kids.cache
src/kids/cache/__init__.py
undecorate
def undecorate(func): """Returns the decorator and the undecorated function of given object.""" orig_call_wrapper = lambda x: x for call_wrapper, unwrap in SUPPORTED_DECORATOR.items(): if isinstance(func, call_wrapper): func = unwrap(func) orig_call_wrapper = call_wrapper ...
python
def undecorate(func): """Returns the decorator and the undecorated function of given object.""" orig_call_wrapper = lambda x: x for call_wrapper, unwrap in SUPPORTED_DECORATOR.items(): if isinstance(func, call_wrapper): func = unwrap(func) orig_call_wrapper = call_wrapper ...
[ "def", "undecorate", "(", "func", ")", ":", "orig_call_wrapper", "=", "lambda", "x", ":", "x", "for", "call_wrapper", ",", "unwrap", "in", "SUPPORTED_DECORATOR", ".", "items", "(", ")", ":", "if", "isinstance", "(", "func", ",", "call_wrapper", ")", ":", ...
Returns the decorator and the undecorated function of given object.
[ "Returns", "the", "decorator", "and", "the", "undecorated", "function", "of", "given", "object", "." ]
668f3b966877c4a0855d60e05cc3706cf37e4570
https://github.com/0k/kids.cache/blob/668f3b966877c4a0855d60e05cc3706cf37e4570/src/kids/cache/__init__.py#L82-L90
train
idlesign/steampak
steampak/cli.py
item
def item(ctx, appid, title): """Market-related commands.""" ctx.obj['appid'] = appid ctx.obj['title'] = title
python
def item(ctx, appid, title): """Market-related commands.""" ctx.obj['appid'] = appid ctx.obj['title'] = title
[ "def", "item", "(", "ctx", ",", "appid", ",", "title", ")", ":", "ctx", ".", "obj", "[", "'appid'", "]", "=", "appid", "ctx", ".", "obj", "[", "'title'", "]", "=", "title" ]
Market-related commands.
[ "Market", "-", "related", "commands", "." ]
cb3f2c737e272b0360802d947e388df7e34f50f3
https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/cli.py#L111-L114
train
idlesign/steampak
steampak/cli.py
get_price
def get_price(ctx, currency): """Prints out market item price.""" appid = ctx.obj['appid'] title = ctx.obj['title'] item_ = Item(appid, title) item_.get_price_data(currency) click.secho('Lowest price: %s %s' % (item_.price_lowest, item_.price_currency), fg='green')
python
def get_price(ctx, currency): """Prints out market item price.""" appid = ctx.obj['appid'] title = ctx.obj['title'] item_ = Item(appid, title) item_.get_price_data(currency) click.secho('Lowest price: %s %s' % (item_.price_lowest, item_.price_currency), fg='green')
[ "def", "get_price", "(", "ctx", ",", "currency", ")", ":", "appid", "=", "ctx", ".", "obj", "[", "'appid'", "]", "title", "=", "ctx", ".", "obj", "[", "'title'", "]", "item_", "=", "Item", "(", "appid", ",", "title", ")", "item_", ".", "get_price_d...
Prints out market item price.
[ "Prints", "out", "market", "item", "price", "." ]
cb3f2c737e272b0360802d947e388df7e34f50f3
https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/cli.py#L120-L128
train
idlesign/steampak
steampak/cli.py
get_cards
def get_cards(ctx): """Prints out cards available for application.""" appid = ctx.obj['appid'] app = Application(appid) click.secho('Cards for `%s` [appid: %s]' % (app.title, appid), fg='green') if not app.has_cards: click.secho('This app has no cards.', fg='red', err=True) return...
python
def get_cards(ctx): """Prints out cards available for application.""" appid = ctx.obj['appid'] app = Application(appid) click.secho('Cards for `%s` [appid: %s]' % (app.title, appid), fg='green') if not app.has_cards: click.secho('This app has no cards.', fg='red', err=True) return...
[ "def", "get_cards", "(", "ctx", ")", ":", "appid", "=", "ctx", ".", "obj", "[", "'appid'", "]", "app", "=", "Application", "(", "appid", ")", "click", ".", "secho", "(", "'Cards for `%s` [appid: %s]'", "%", "(", "app", ".", "title", ",", "appid", ")", ...
Prints out cards available for application.
[ "Prints", "out", "cards", "available", "for", "application", "." ]
cb3f2c737e272b0360802d947e388df7e34f50f3
https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/cli.py#L141-L164
train
idlesign/steampak
steampak/cli.py
get_card_prices
def get_card_prices(ctx, currency): """Prints out lowest card prices for an application. Comma-separated list of application IDs is supported. """ appid = ctx.obj['appid'] detailed = True appids = [appid] if ',' in appid: appids = [appid.strip() for appid in appid.split(',')] ...
python
def get_card_prices(ctx, currency): """Prints out lowest card prices for an application. Comma-separated list of application IDs is supported. """ appid = ctx.obj['appid'] detailed = True appids = [appid] if ',' in appid: appids = [appid.strip() for appid in appid.split(',')] ...
[ "def", "get_card_prices", "(", "ctx", ",", "currency", ")", ":", "appid", "=", "ctx", ".", "obj", "[", "'appid'", "]", "detailed", "=", "True", "appids", "=", "[", "appid", "]", "if", "','", "in", "appid", ":", "appids", "=", "[", "appid", ".", "st...
Prints out lowest card prices for an application. Comma-separated list of application IDs is supported.
[ "Prints", "out", "lowest", "card", "prices", "for", "an", "application", ".", "Comma", "-", "separated", "list", "of", "application", "IDs", "is", "supported", "." ]
cb3f2c737e272b0360802d947e388df7e34f50f3
https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/cli.py#L170-L186
train
idlesign/steampak
steampak/cli.py
get_gems
def get_gems(ctx): """Prints out total gems count for a Steam user.""" username = ctx.obj['username'] click.secho( 'Total gems owned by `%s`: %d' % (username, User(username).gems_total), fg='green')
python
def get_gems(ctx): """Prints out total gems count for a Steam user.""" username = ctx.obj['username'] click.secho( 'Total gems owned by `%s`: %d' % (username, User(username).gems_total), fg='green')
[ "def", "get_gems", "(", "ctx", ")", ":", "username", "=", "ctx", ".", "obj", "[", "'username'", "]", "click", ".", "secho", "(", "'Total gems owned by `%s`: %d'", "%", "(", "username", ",", "User", "(", "username", ")", ".", "gems_total", ")", ",", "fg",...
Prints out total gems count for a Steam user.
[ "Prints", "out", "total", "gems", "count", "for", "a", "Steam", "user", "." ]
cb3f2c737e272b0360802d947e388df7e34f50f3
https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/cli.py#L199-L205
train
idlesign/steampak
steampak/cli.py
get_games
def get_games(ctx): """Prints out games owned by a Steam user.""" username = ctx.obj['username'] games = User(username).get_games_owned() for game in sorted(games.values(), key=itemgetter('title')): click.echo('%s [appid: %s]' % (game['title'], game['appid'])) click.secho('Total gems owne...
python
def get_games(ctx): """Prints out games owned by a Steam user.""" username = ctx.obj['username'] games = User(username).get_games_owned() for game in sorted(games.values(), key=itemgetter('title')): click.echo('%s [appid: %s]' % (game['title'], game['appid'])) click.secho('Total gems owne...
[ "def", "get_games", "(", "ctx", ")", ":", "username", "=", "ctx", ".", "obj", "[", "'username'", "]", "games", "=", "User", "(", "username", ")", ".", "get_games_owned", "(", ")", "for", "game", "in", "sorted", "(", "games", ".", "values", "(", ")", ...
Prints out games owned by a Steam user.
[ "Prints", "out", "games", "owned", "by", "a", "Steam", "user", "." ]
cb3f2c737e272b0360802d947e388df7e34f50f3
https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/cli.py#L210-L219
train
idlesign/steampak
steampak/cli.py
get_booster_stats
def get_booster_stats(ctx, currency): """Prints out price stats for booster packs available in Steam user inventory.""" username = ctx.obj['username'] inventory = User(username)._get_inventory_raw() boosters = {} for item in inventory['rgDescriptions'].values(): is_booster = False ...
python
def get_booster_stats(ctx, currency): """Prints out price stats for booster packs available in Steam user inventory.""" username = ctx.obj['username'] inventory = User(username)._get_inventory_raw() boosters = {} for item in inventory['rgDescriptions'].values(): is_booster = False ...
[ "def", "get_booster_stats", "(", "ctx", ",", "currency", ")", ":", "username", "=", "ctx", ".", "obj", "[", "'username'", "]", "inventory", "=", "User", "(", "username", ")", ".", "_get_inventory_raw", "(", ")", "boosters", "=", "{", "}", "for", "item", ...
Prints out price stats for booster packs available in Steam user inventory.
[ "Prints", "out", "price", "stats", "for", "booster", "packs", "available", "in", "Steam", "user", "inventory", "." ]
cb3f2c737e272b0360802d947e388df7e34f50f3
https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/cli.py#L225-L255
train
idlesign/steampak
steampak/cli.py
get_cards_stats
def get_cards_stats(ctx, currency, skip_owned, appid, foil): """Prints out price stats for cards available in Steam user inventory.""" username = ctx.obj['username'] cards_by_app = defaultdict(list) inventory = User(username).traverse_inventory(item_filter=TAG_ITEM_CLASS_CARD) for item in inventor...
python
def get_cards_stats(ctx, currency, skip_owned, appid, foil): """Prints out price stats for cards available in Steam user inventory.""" username = ctx.obj['username'] cards_by_app = defaultdict(list) inventory = User(username).traverse_inventory(item_filter=TAG_ITEM_CLASS_CARD) for item in inventor...
[ "def", "get_cards_stats", "(", "ctx", ",", "currency", ",", "skip_owned", ",", "appid", ",", "foil", ")", ":", "username", "=", "ctx", ".", "obj", "[", "'username'", "]", "cards_by_app", "=", "defaultdict", "(", "list", ")", "inventory", "=", "User", "("...
Prints out price stats for cards available in Steam user inventory.
[ "Prints", "out", "price", "stats", "for", "cards", "available", "in", "Steam", "user", "inventory", "." ]
cb3f2c737e272b0360802d947e388df7e34f50f3
https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/cli.py#L264-L287
train
BD2KGenomics/protect
src/protect/mutation_calling/radia.py
run_radia_with_merge
def run_radia_with_merge(job, rna_bam, tumor_bam, normal_bam, univ_options, radia_options): """ A wrapper for the the entire RADIA sub-graph. :param dict rna_bam: Dict dicts of bam and bai for tumor RNA-Seq obtained by running STAR within ProTECT. :param dict tumor_bam: Dict of bam and bai f...
python
def run_radia_with_merge(job, rna_bam, tumor_bam, normal_bam, univ_options, radia_options): """ A wrapper for the the entire RADIA sub-graph. :param dict rna_bam: Dict dicts of bam and bai for tumor RNA-Seq obtained by running STAR within ProTECT. :param dict tumor_bam: Dict of bam and bai f...
[ "def", "run_radia_with_merge", "(", "job", ",", "rna_bam", ",", "tumor_bam", ",", "normal_bam", ",", "univ_options", ",", "radia_options", ")", ":", "spawn", "=", "job", ".", "wrapJobFn", "(", "run_radia", ",", "rna_bam", "[", "'rna_genome'", "]", ",", "tumo...
A wrapper for the the entire RADIA sub-graph. :param dict rna_bam: Dict dicts of bam and bai for tumor RNA-Seq obtained by running STAR within ProTECT. :param dict tumor_bam: Dict of bam and bai for tumor DNA-Seq :param dict normal_bam: Dict of bam and bai for normal DNA-Seq :param dict univ...
[ "A", "wrapper", "for", "the", "the", "entire", "RADIA", "sub", "-", "graph", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/radia.py#L40-L59
train
BD2KGenomics/protect
src/protect/mutation_calling/radia.py
run_radia
def run_radia(job, rna_bam, tumor_bam, normal_bam, univ_options, radia_options): """ Spawn a RADIA job for each chromosome on the input bam trios. :param dict rna_bam: Dict of bam and bai for tumor DNA-Seq. It can be one of two formats rna_bam: # Just the genomic bam and bai |...
python
def run_radia(job, rna_bam, tumor_bam, normal_bam, univ_options, radia_options): """ Spawn a RADIA job for each chromosome on the input bam trios. :param dict rna_bam: Dict of bam and bai for tumor DNA-Seq. It can be one of two formats rna_bam: # Just the genomic bam and bai |...
[ "def", "run_radia", "(", "job", ",", "rna_bam", ",", "tumor_bam", ",", "normal_bam", ",", "univ_options", ",", "radia_options", ")", ":", "if", "'rna_genome'", "in", "rna_bam", ".", "keys", "(", ")", ":", "rna_bam", "=", "rna_bam", "[", "'rna_genome'", "]"...
Spawn a RADIA job for each chromosome on the input bam trios. :param dict rna_bam: Dict of bam and bai for tumor DNA-Seq. It can be one of two formats rna_bam: # Just the genomic bam and bai |- 'rna_genome_sorted.bam': fsID +- 'rna_genome_sorted.bam.bai': fsID ...
[ "Spawn", "a", "RADIA", "job", "for", "each", "chromosome", "on", "the", "input", "bam", "trios", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/radia.py#L62-L126
train
BD2KGenomics/protect
src/protect/mutation_calling/radia.py
run_radia_perchrom
def run_radia_perchrom(job, bams, univ_options, radia_options, chrom): """ Run RADIA call on a single chromosome in the input bams. :param dict bams: Dict of bam and bai for tumor DNA-Seq, normal DNA-Seq and tumor RNA-Seq :param dict univ_options: Dict of universal options used by almost all tools ...
python
def run_radia_perchrom(job, bams, univ_options, radia_options, chrom): """ Run RADIA call on a single chromosome in the input bams. :param dict bams: Dict of bam and bai for tumor DNA-Seq, normal DNA-Seq and tumor RNA-Seq :param dict univ_options: Dict of universal options used by almost all tools ...
[ "def", "run_radia_perchrom", "(", "job", ",", "bams", ",", "univ_options", ",", "radia_options", ",", "chrom", ")", ":", "work_dir", "=", "os", ".", "getcwd", "(", ")", "input_files", "=", "{", "'rna.bam'", ":", "bams", "[", "'tumor_rna'", "]", ",", "'rn...
Run RADIA call on a single chromosome in the input bams. :param dict bams: Dict of bam and bai for tumor DNA-Seq, normal DNA-Seq and tumor RNA-Seq :param dict univ_options: Dict of universal options used by almost all tools :param dict radia_options: Options specific to RADIA :param str chrom: Chromoso...
[ "Run", "RADIA", "call", "on", "a", "single", "chromosome", "in", "the", "input", "bams", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/radia.py#L129-L178
train
BD2KGenomics/protect
src/protect/mutation_calling/radia.py
run_filter_radia
def run_filter_radia(job, bams, radia_file, univ_options, radia_options, chrom): """ Run filterradia on the RADIA output. :param dict bams: Dict of bam and bai for tumor DNA-Seq, normal DNA-Seq and tumor RNA-Seq :param toil.fileStore.FileID radia_file: The vcf from runnning RADIA :param dict univ_o...
python
def run_filter_radia(job, bams, radia_file, univ_options, radia_options, chrom): """ Run filterradia on the RADIA output. :param dict bams: Dict of bam and bai for tumor DNA-Seq, normal DNA-Seq and tumor RNA-Seq :param toil.fileStore.FileID radia_file: The vcf from runnning RADIA :param dict univ_o...
[ "def", "run_filter_radia", "(", "job", ",", "bams", ",", "radia_file", ",", "univ_options", ",", "radia_options", ",", "chrom", ")", ":", "work_dir", "=", "os", ".", "getcwd", "(", ")", "input_files", "=", "{", "'rna.bam'", ":", "bams", "[", "'tumor_rna'",...
Run filterradia on the RADIA output. :param dict bams: Dict of bam and bai for tumor DNA-Seq, normal DNA-Seq and tumor RNA-Seq :param toil.fileStore.FileID radia_file: The vcf from runnning RADIA :param dict univ_options: Dict of universal options used by almost all tools :param dict radia_options: Opt...
[ "Run", "filterradia", "on", "the", "RADIA", "output", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/radia.py#L181-L246
train
BD2KGenomics/protect
src/protect/alignment/common.py
index_bamfile
def index_bamfile(job, bamfile, sample_type, univ_options, samtools_options, sample_info=None, export=True): """ Index `bamfile` using samtools :param toil.fileStore.FileID bamfile: fsID for the bam file :param str sample_type: Description of the sample to inject into the filename ...
python
def index_bamfile(job, bamfile, sample_type, univ_options, samtools_options, sample_info=None, export=True): """ Index `bamfile` using samtools :param toil.fileStore.FileID bamfile: fsID for the bam file :param str sample_type: Description of the sample to inject into the filename ...
[ "def", "index_bamfile", "(", "job", ",", "bamfile", ",", "sample_type", ",", "univ_options", ",", "samtools_options", ",", "sample_info", "=", "None", ",", "export", "=", "True", ")", ":", "work_dir", "=", "os", ".", "getcwd", "(", ")", "in_bamfile", "=", ...
Index `bamfile` using samtools :param toil.fileStore.FileID bamfile: fsID for the bam file :param str sample_type: Description of the sample to inject into the filename :param dict univ_options: Dict of universal options used by almost all tools :param dict samtools_options: Options specific to samtool...
[ "Index", "bamfile", "using", "samtools" ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/alignment/common.py#L33-L74
train
BD2KGenomics/protect
src/protect/alignment/common.py
sort_bamfile
def sort_bamfile(job, bamfile, sample_type, univ_options, samtools_options): """ Sort `bamfile` using samtools :param toil.fileStore.FileID bamfile: fsID for the bam file :param str sample_type: Description of the sample to inject into the filename :param dict univ_options: Dict of universal option...
python
def sort_bamfile(job, bamfile, sample_type, univ_options, samtools_options): """ Sort `bamfile` using samtools :param toil.fileStore.FileID bamfile: fsID for the bam file :param str sample_type: Description of the sample to inject into the filename :param dict univ_options: Dict of universal option...
[ "def", "sort_bamfile", "(", "job", ",", "bamfile", ",", "sample_type", ",", "univ_options", ",", "samtools_options", ")", ":", "work_dir", "=", "os", ".", "getcwd", "(", ")", "in_bamfile", "=", "''", ".", "join", "(", "[", "sample_type", ",", "'.bam'", "...
Sort `bamfile` using samtools :param toil.fileStore.FileID bamfile: fsID for the bam file :param str sample_type: Description of the sample to inject into the filename :param dict univ_options: Dict of universal options used by almost all tools :param dict samtools_options: Options specific to samtools...
[ "Sort", "bamfile", "using", "samtools" ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/alignment/common.py#L77-L105
train
inveniosoftware/invenio-access
invenio_access/utils.py
get_identity
def get_identity(user): """Create an identity for a given user instance. Primarily useful for testing. """ identity = Identity(user.id) if hasattr(user, 'id'): identity.provides.add(UserNeed(user.id)) for role in getattr(user, 'roles', []): identity.provides.add(RoleNeed(role....
python
def get_identity(user): """Create an identity for a given user instance. Primarily useful for testing. """ identity = Identity(user.id) if hasattr(user, 'id'): identity.provides.add(UserNeed(user.id)) for role in getattr(user, 'roles', []): identity.provides.add(RoleNeed(role....
[ "def", "get_identity", "(", "user", ")", ":", "identity", "=", "Identity", "(", "user", ".", "id", ")", "if", "hasattr", "(", "user", ",", "'id'", ")", ":", "identity", ".", "provides", ".", "add", "(", "UserNeed", "(", "user", ".", "id", ")", ")",...
Create an identity for a given user instance. Primarily useful for testing.
[ "Create", "an", "identity", "for", "a", "given", "user", "instance", "." ]
3b033a4bdc110eb2f7e9f08f0744a780884bfc80
https://github.com/inveniosoftware/invenio-access/blob/3b033a4bdc110eb2f7e9f08f0744a780884bfc80/invenio_access/utils.py#L16-L30
train
adfinis-sygroup/freeze
freeze/xfreeze.py
object_to_items
def object_to_items(data_structure): """Converts a object to a items list respecting also slots. Use dict(object_to_items(obj)) to get a dictionary.""" items = [] # Get all items from dict try: items = list(data_structure.__dict__.items()) except: pass # Get all slots hi...
python
def object_to_items(data_structure): """Converts a object to a items list respecting also slots. Use dict(object_to_items(obj)) to get a dictionary.""" items = [] # Get all items from dict try: items = list(data_structure.__dict__.items()) except: pass # Get all slots hi...
[ "def", "object_to_items", "(", "data_structure", ")", ":", "items", "=", "[", "]", "try", ":", "items", "=", "list", "(", "data_structure", ".", "__dict__", ".", "items", "(", ")", ")", "except", ":", "pass", "hierarchy", "=", "[", "data_structure", "]",...
Converts a object to a items list respecting also slots. Use dict(object_to_items(obj)) to get a dictionary.
[ "Converts", "a", "object", "to", "a", "items", "list", "respecting", "also", "slots", "." ]
61b4fab8a90ed76d685448723baaa57e2bbd5ef9
https://github.com/adfinis-sygroup/freeze/blob/61b4fab8a90ed76d685448723baaa57e2bbd5ef9/freeze/xfreeze.py#L251-L279
train
adfinis-sygroup/freeze
freeze/xfreeze.py
recursive_sort
def recursive_sort(data_structure): """Sort a recursive data_structure. :param data_structure: The structure to convert. data_structure must be already sortable or you must use freeze() or dump(). The function will work with many kinds of input. Dictionaries will be converted to lists of tuples....
python
def recursive_sort(data_structure): """Sort a recursive data_structure. :param data_structure: The structure to convert. data_structure must be already sortable or you must use freeze() or dump(). The function will work with many kinds of input. Dictionaries will be converted to lists of tuples....
[ "def", "recursive_sort", "(", "data_structure", ")", ":", "if", "not", "isinstance", "(", "data_structure", ",", "_primitive_types", ")", ":", "is_meta", "=", "isinstance", "(", "data_structure", ",", "Meta", ")", "was_dict", "=", "isinstance", "(", "data_struct...
Sort a recursive data_structure. :param data_structure: The structure to convert. data_structure must be already sortable or you must use freeze() or dump(). The function will work with many kinds of input. Dictionaries will be converted to lists of tuples. >>> _py2_to_py3(vformat(recursive_sor...
[ "Sort", "a", "recursive", "data_structure", "." ]
61b4fab8a90ed76d685448723baaa57e2bbd5ef9
https://github.com/adfinis-sygroup/freeze/blob/61b4fab8a90ed76d685448723baaa57e2bbd5ef9/freeze/xfreeze.py#L531-L611
train
adfinis-sygroup/freeze
freeze/xfreeze.py
traverse_frozen_data
def traverse_frozen_data(data_structure): """Yields the leaves of the frozen data-structure pre-order. It will produce the same order as one would write the data-structure.""" parent_stack = [data_structure] while parent_stack: node = parent_stack.pop(0) # We don't iterate strings ...
python
def traverse_frozen_data(data_structure): """Yields the leaves of the frozen data-structure pre-order. It will produce the same order as one would write the data-structure.""" parent_stack = [data_structure] while parent_stack: node = parent_stack.pop(0) # We don't iterate strings ...
[ "def", "traverse_frozen_data", "(", "data_structure", ")", ":", "parent_stack", "=", "[", "data_structure", "]", "while", "parent_stack", ":", "node", "=", "parent_stack", ".", "pop", "(", "0", ")", "tlen", "=", "-", "1", "if", "not", "isinstance", "(", "n...
Yields the leaves of the frozen data-structure pre-order. It will produce the same order as one would write the data-structure.
[ "Yields", "the", "leaves", "of", "the", "frozen", "data", "-", "structure", "pre", "-", "order", "." ]
61b4fab8a90ed76d685448723baaa57e2bbd5ef9
https://github.com/adfinis-sygroup/freeze/blob/61b4fab8a90ed76d685448723baaa57e2bbd5ef9/freeze/xfreeze.py#L665-L683
train
adfinis-sygroup/freeze
freeze/xfreeze.py
tree_diff
def tree_diff(a, b, n=5, sort=False): """Dump any data-structure or object, traverse it depth-first in-order and apply a unified diff. Depth-first in-order is just like structure would be printed. :param a: data_structure a :param b: data_structure b :param ...
python
def tree_diff(a, b, n=5, sort=False): """Dump any data-structure or object, traverse it depth-first in-order and apply a unified diff. Depth-first in-order is just like structure would be printed. :param a: data_structure a :param b: data_structure b :param ...
[ "def", "tree_diff", "(", "a", ",", "b", ",", "n", "=", "5", ",", "sort", "=", "False", ")", ":", "a", "=", "dump", "(", "a", ")", "b", "=", "dump", "(", "b", ")", "if", "not", "sort", ":", "a", "=", "vformat", "(", "a", ")", ".", "split",...
Dump any data-structure or object, traverse it depth-first in-order and apply a unified diff. Depth-first in-order is just like structure would be printed. :param a: data_structure a :param b: data_structure b :param n: lines of context :type n:...
[ "Dump", "any", "data", "-", "structure", "or", "object", "traverse", "it", "depth", "-", "first", "in", "-", "order", "and", "apply", "a", "unified", "diff", "." ]
61b4fab8a90ed76d685448723baaa57e2bbd5ef9
https://github.com/adfinis-sygroup/freeze/blob/61b4fab8a90ed76d685448723baaa57e2bbd5ef9/freeze/xfreeze.py#L752-L823
train
idlesign/steampak
steampak/libsteam/resources/groups.py
Group.stats
def stats(self): """Basic group statistics. Returned dict has the following keys: 'online' - users online count 'ingame' - users currently in game count 'chatting' - users chatting count :return: dict """ stats_online = CRef.cint() s...
python
def stats(self): """Basic group statistics. Returned dict has the following keys: 'online' - users online count 'ingame' - users currently in game count 'chatting' - users chatting count :return: dict """ stats_online = CRef.cint() s...
[ "def", "stats", "(", "self", ")", ":", "stats_online", "=", "CRef", ".", "cint", "(", ")", "stats_ingame", "=", "CRef", ".", "cint", "(", ")", "stats_chatting", "=", "CRef", ".", "cint", "(", ")", "self", ".", "_iface", ".", "get_clan_stats", "(", "s...
Basic group statistics. Returned dict has the following keys: 'online' - users online count 'ingame' - users currently in game count 'chatting' - users chatting count :return: dict
[ "Basic", "group", "statistics", "." ]
cb3f2c737e272b0360802d947e388df7e34f50f3
https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/libsteam/resources/groups.py#L24-L50
train
budacom/trading-bots
trading_bots/core/management/__init__.py
startproject
def startproject(name, directory, verbosity): """ Creates a Trading-Bots project directory structure for the given project NAME in the current directory or optionally in the given DIRECTORY. """ handle_template('project', name, target=directory, verbosity=verbosity) click.echo(f"Success: '{name}...
python
def startproject(name, directory, verbosity): """ Creates a Trading-Bots project directory structure for the given project NAME in the current directory or optionally in the given DIRECTORY. """ handle_template('project', name, target=directory, verbosity=verbosity) click.echo(f"Success: '{name}...
[ "def", "startproject", "(", "name", ",", "directory", ",", "verbosity", ")", ":", "handle_template", "(", "'project'", ",", "name", ",", "target", "=", "directory", ",", "verbosity", "=", "verbosity", ")", "click", ".", "echo", "(", "f\"Success: '{name}' proje...
Creates a Trading-Bots project directory structure for the given project NAME in the current directory or optionally in the given DIRECTORY.
[ "Creates", "a", "Trading", "-", "Bots", "project", "directory", "structure", "for", "the", "given", "project", "NAME", "in", "the", "current", "directory", "or", "optionally", "in", "the", "given", "DIRECTORY", "." ]
8cb68bb8d0b5f822108db1cc5dae336e3d3c3452
https://github.com/budacom/trading-bots/blob/8cb68bb8d0b5f822108db1cc5dae336e3d3c3452/trading_bots/core/management/__init__.py#L101-L107
train
budacom/trading-bots
trading_bots/core/management/__init__.py
createbot
def createbot(name, directory, verbosity): """ Creates a Bot's directory structure for the given bot NAME in the current directory or optionally in the given DIRECTORY. """ handle_template('bot', name, target=directory, verbosity=verbosity) click.echo(f"Success: '{name}' bot was successfully cre...
python
def createbot(name, directory, verbosity): """ Creates a Bot's directory structure for the given bot NAME in the current directory or optionally in the given DIRECTORY. """ handle_template('bot', name, target=directory, verbosity=verbosity) click.echo(f"Success: '{name}' bot was successfully cre...
[ "def", "createbot", "(", "name", ",", "directory", ",", "verbosity", ")", ":", "handle_template", "(", "'bot'", ",", "name", ",", "target", "=", "directory", ",", "verbosity", "=", "verbosity", ")", "click", ".", "echo", "(", "f\"Success: '{name}' bot was succ...
Creates a Bot's directory structure for the given bot NAME in the current directory or optionally in the given DIRECTORY.
[ "Creates", "a", "Bot", "s", "directory", "structure", "for", "the", "given", "bot", "NAME", "in", "the", "current", "directory", "or", "optionally", "in", "the", "given", "DIRECTORY", "." ]
8cb68bb8d0b5f822108db1cc5dae336e3d3c3452
https://github.com/budacom/trading-bots/blob/8cb68bb8d0b5f822108db1cc5dae336e3d3c3452/trading_bots/core/management/__init__.py#L114-L120
train
idlesign/steampak
steampak/libsteam/resources/user.py
User.get_state
def get_state(self, as_str=False): """Returns user state. See ``UserState``. :param bool as_str: Return human-friendly state name instead of an ID. :rtype: int|str """ uid = self.user_id if self._iface_user.get_id() == uid: result = self._iface.get_my_state...
python
def get_state(self, as_str=False): """Returns user state. See ``UserState``. :param bool as_str: Return human-friendly state name instead of an ID. :rtype: int|str """ uid = self.user_id if self._iface_user.get_id() == uid: result = self._iface.get_my_state...
[ "def", "get_state", "(", "self", ",", "as_str", "=", "False", ")", ":", "uid", "=", "self", ".", "user_id", "if", "self", ".", "_iface_user", ".", "get_id", "(", ")", "==", "uid", ":", "result", "=", "self", ".", "_iface", ".", "get_my_state", "(", ...
Returns user state. See ``UserState``. :param bool as_str: Return human-friendly state name instead of an ID. :rtype: int|str
[ "Returns", "user", "state", ".", "See", "UserState", "." ]
cb3f2c737e272b0360802d947e388df7e34f50f3
https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/libsteam/resources/user.py#L95-L113
train
inveniosoftware/invenio-access
invenio_access/loaders.py
load_permissions_on_identity_loaded
def load_permissions_on_identity_loaded(sender, identity): """Add system roles "Needs" to users' identities. Every user gets the **any_user** Need. Authenticated users get in addition the **authenticated_user** Need. """ identity.provides.add( any_user ) # if the user is not anonymo...
python
def load_permissions_on_identity_loaded(sender, identity): """Add system roles "Needs" to users' identities. Every user gets the **any_user** Need. Authenticated users get in addition the **authenticated_user** Need. """ identity.provides.add( any_user ) # if the user is not anonymo...
[ "def", "load_permissions_on_identity_loaded", "(", "sender", ",", "identity", ")", ":", "identity", ".", "provides", ".", "add", "(", "any_user", ")", "if", "current_user", ".", "is_authenticated", ":", "identity", ".", "provides", ".", "add", "(", "authenticate...
Add system roles "Needs" to users' identities. Every user gets the **any_user** Need. Authenticated users get in addition the **authenticated_user** Need.
[ "Add", "system", "roles", "Needs", "to", "users", "identities", "." ]
3b033a4bdc110eb2f7e9f08f0744a780884bfc80
https://github.com/inveniosoftware/invenio-access/blob/3b033a4bdc110eb2f7e9f08f0744a780884bfc80/invenio_access/loaders.py#L15-L29
train
HEPData/hepdata-validator
hepdata_validator/__init__.py
Validator.print_errors
def print_errors(self, file_name): """ Prints the errors observed for a file """ for error in self.get_messages(file_name): print('\t', error.__unicode__())
python
def print_errors(self, file_name): """ Prints the errors observed for a file """ for error in self.get_messages(file_name): print('\t', error.__unicode__())
[ "def", "print_errors", "(", "self", ",", "file_name", ")", ":", "for", "error", "in", "self", ".", "get_messages", "(", "file_name", ")", ":", "print", "(", "'\\t'", ",", "error", ".", "__unicode__", "(", ")", ")" ]
Prints the errors observed for a file
[ "Prints", "the", "errors", "observed", "for", "a", "file" ]
d0b0cab742a009c8f0e8aac9f8c8e434a524d43c
https://github.com/HEPData/hepdata-validator/blob/d0b0cab742a009c8f0e8aac9f8c8e434a524d43c/hepdata_validator/__init__.py#L98-L103
train
bkg/django-spillway
spillway/forms/forms.py
RasterQueryForm.clean
def clean(self): """Return cleaned fields as a dict, determine which geom takes precedence. """ data = super(RasterQueryForm, self).clean() geom = data.pop('upload', None) or data.pop('bbox', None) if geom: data['g'] = geom return data
python
def clean(self): """Return cleaned fields as a dict, determine which geom takes precedence. """ data = super(RasterQueryForm, self).clean() geom = data.pop('upload', None) or data.pop('bbox', None) if geom: data['g'] = geom return data
[ "def", "clean", "(", "self", ")", ":", "data", "=", "super", "(", "RasterQueryForm", ",", "self", ")", ".", "clean", "(", ")", "geom", "=", "data", ".", "pop", "(", "'upload'", ",", "None", ")", "or", "data", ".", "pop", "(", "'bbox'", ",", "None...
Return cleaned fields as a dict, determine which geom takes precedence.
[ "Return", "cleaned", "fields", "as", "a", "dict", "determine", "which", "geom", "takes", "precedence", "." ]
c488a62642430b005f1e0d4a19e160d8d5964b67
https://github.com/bkg/django-spillway/blob/c488a62642430b005f1e0d4a19e160d8d5964b67/spillway/forms/forms.py#L125-L133
train
drslump/pyshould
pyshould/matchers.py
register
def register(matcher, *aliases): """ Register a matcher associated to one or more aliases. Each alias given is also normalized. """ docstr = matcher.__doc__ if matcher.__doc__ is not None else '' helpmatchers[matcher] = docstr.strip() for alias in aliases: matchers[alias] = matcher ...
python
def register(matcher, *aliases): """ Register a matcher associated to one or more aliases. Each alias given is also normalized. """ docstr = matcher.__doc__ if matcher.__doc__ is not None else '' helpmatchers[matcher] = docstr.strip() for alias in aliases: matchers[alias] = matcher ...
[ "def", "register", "(", "matcher", ",", "*", "aliases", ")", ":", "docstr", "=", "matcher", ".", "__doc__", "if", "matcher", ".", "__doc__", "is", "not", "None", "else", "''", "helpmatchers", "[", "matcher", "]", "=", "docstr", ".", "strip", "(", ")", ...
Register a matcher associated to one or more aliases. Each alias given is also normalized.
[ "Register", "a", "matcher", "associated", "to", "one", "or", "more", "aliases", ".", "Each", "alias", "given", "is", "also", "normalized", "." ]
7210859d4c84cfbaa64f91b30c2a541aea788ddf
https://github.com/drslump/pyshould/blob/7210859d4c84cfbaa64f91b30c2a541aea788ddf/pyshould/matchers.py#L54-L68
train
drslump/pyshould
pyshould/matchers.py
normalize
def normalize(alias): """ Normalizes an alias by removing adverbs defined in IGNORED_WORDS """ # Convert from CamelCase to snake_case alias = re.sub(r'([a-z])([A-Z])', r'\1_\2', alias) # Ignore words words = alias.lower().split('_') words = filter(lambda w: w not in IGNORED_WORDS, words) ...
python
def normalize(alias): """ Normalizes an alias by removing adverbs defined in IGNORED_WORDS """ # Convert from CamelCase to snake_case alias = re.sub(r'([a-z])([A-Z])', r'\1_\2', alias) # Ignore words words = alias.lower().split('_') words = filter(lambda w: w not in IGNORED_WORDS, words) ...
[ "def", "normalize", "(", "alias", ")", ":", "alias", "=", "re", ".", "sub", "(", "r'([a-z])([A-Z])'", ",", "r'\\1_\\2'", ",", "alias", ")", "words", "=", "alias", ".", "lower", "(", ")", ".", "split", "(", "'_'", ")", "words", "=", "filter", "(", "...
Normalizes an alias by removing adverbs defined in IGNORED_WORDS
[ "Normalizes", "an", "alias", "by", "removing", "adverbs", "defined", "in", "IGNORED_WORDS" ]
7210859d4c84cfbaa64f91b30c2a541aea788ddf
https://github.com/drslump/pyshould/blob/7210859d4c84cfbaa64f91b30c2a541aea788ddf/pyshould/matchers.py#L94-L102
train
drslump/pyshould
pyshould/matchers.py
lookup
def lookup(alias): """ Tries to find a matcher callable associated to the given alias. If an exact match does not exists it will try normalizing it and even removing underscores to find one. """ if alias in matchers: return matchers[alias] else: norm = normalize(alias) ...
python
def lookup(alias): """ Tries to find a matcher callable associated to the given alias. If an exact match does not exists it will try normalizing it and even removing underscores to find one. """ if alias in matchers: return matchers[alias] else: norm = normalize(alias) ...
[ "def", "lookup", "(", "alias", ")", ":", "if", "alias", "in", "matchers", ":", "return", "matchers", "[", "alias", "]", "else", ":", "norm", "=", "normalize", "(", "alias", ")", "if", "norm", "in", "normalized", ":", "alias", "=", "normalized", "[", ...
Tries to find a matcher callable associated to the given alias. If an exact match does not exists it will try normalizing it and even removing underscores to find one.
[ "Tries", "to", "find", "a", "matcher", "callable", "associated", "to", "the", "given", "alias", ".", "If", "an", "exact", "match", "does", "not", "exists", "it", "will", "try", "normalizing", "it", "and", "even", "removing", "underscores", "to", "find", "o...
7210859d4c84cfbaa64f91b30c2a541aea788ddf
https://github.com/drslump/pyshould/blob/7210859d4c84cfbaa64f91b30c2a541aea788ddf/pyshould/matchers.py#L105-L124
train
drslump/pyshould
pyshould/matchers.py
suggest
def suggest(alias, max=3, cutoff=0.5): """ Suggest a list of aliases which are similar enough """ aliases = matchers.keys() similar = get_close_matches(alias, aliases, n=max, cutoff=cutoff) return similar
python
def suggest(alias, max=3, cutoff=0.5): """ Suggest a list of aliases which are similar enough """ aliases = matchers.keys() similar = get_close_matches(alias, aliases, n=max, cutoff=cutoff) return similar
[ "def", "suggest", "(", "alias", ",", "max", "=", "3", ",", "cutoff", "=", "0.5", ")", ":", "aliases", "=", "matchers", ".", "keys", "(", ")", "similar", "=", "get_close_matches", "(", "alias", ",", "aliases", ",", "n", "=", "max", ",", "cutoff", "=...
Suggest a list of aliases which are similar enough
[ "Suggest", "a", "list", "of", "aliases", "which", "are", "similar", "enough" ]
7210859d4c84cfbaa64f91b30c2a541aea788ddf
https://github.com/drslump/pyshould/blob/7210859d4c84cfbaa64f91b30c2a541aea788ddf/pyshould/matchers.py#L127-L134
train
BD2KGenomics/protect
src/protect/mutation_calling/common.py
sample_chromosomes
def sample_chromosomes(job, genome_fai_file): """ Get a list of chromosomes in the input data. :param toil.fileStore.FileID genome_fai_file: Job store file ID for the genome fai file :return: Chromosomes in the sample :rtype: list[str] """ work_dir = os.getcwd() genome_fai = untargz(job...
python
def sample_chromosomes(job, genome_fai_file): """ Get a list of chromosomes in the input data. :param toil.fileStore.FileID genome_fai_file: Job store file ID for the genome fai file :return: Chromosomes in the sample :rtype: list[str] """ work_dir = os.getcwd() genome_fai = untargz(job...
[ "def", "sample_chromosomes", "(", "job", ",", "genome_fai_file", ")", ":", "work_dir", "=", "os", ".", "getcwd", "(", ")", "genome_fai", "=", "untargz", "(", "job", ".", "fileStore", ".", "readGlobalFile", "(", "genome_fai_file", ")", ",", "work_dir", ")", ...
Get a list of chromosomes in the input data. :param toil.fileStore.FileID genome_fai_file: Job store file ID for the genome fai file :return: Chromosomes in the sample :rtype: list[str]
[ "Get", "a", "list", "of", "chromosomes", "in", "the", "input", "data", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/common.py#L25-L35
train
BD2KGenomics/protect
src/protect/mutation_calling/common.py
run_mutation_aggregator
def run_mutation_aggregator(job, mutation_results, univ_options): """ Aggregate all the called mutations. :param dict mutation_results: Dict of dicts of the various mutation callers in a per chromosome format :param dict univ_options: Dict of universal options used by almost all tools :r...
python
def run_mutation_aggregator(job, mutation_results, univ_options): """ Aggregate all the called mutations. :param dict mutation_results: Dict of dicts of the various mutation callers in a per chromosome format :param dict univ_options: Dict of universal options used by almost all tools :r...
[ "def", "run_mutation_aggregator", "(", "job", ",", "mutation_results", ",", "univ_options", ")", ":", "out", "=", "{", "}", "for", "chrom", "in", "mutation_results", "[", "'mutect'", "]", ".", "keys", "(", ")", ":", "out", "[", "chrom", "]", "=", "job", ...
Aggregate all the called mutations. :param dict mutation_results: Dict of dicts of the various mutation callers in a per chromosome format :param dict univ_options: Dict of universal options used by almost all tools :returns: fsID for the merged mutations file :rtype: toil.fileStore.FileID
[ "Aggregate", "all", "the", "called", "mutations", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/common.py#L54-L71
train
BD2KGenomics/protect
src/protect/mutation_calling/common.py
merge_perchrom_mutations
def merge_perchrom_mutations(job, chrom, mutations, univ_options): """ Merge the mutation calls for a single chromosome. :param str chrom: Chromosome to process :param dict mutations: dict of dicts of the various mutation caller names as keys, and a dict of per chromosome job store ids for v...
python
def merge_perchrom_mutations(job, chrom, mutations, univ_options): """ Merge the mutation calls for a single chromosome. :param str chrom: Chromosome to process :param dict mutations: dict of dicts of the various mutation caller names as keys, and a dict of per chromosome job store ids for v...
[ "def", "merge_perchrom_mutations", "(", "job", ",", "chrom", ",", "mutations", ",", "univ_options", ")", ":", "work_dir", "=", "os", ".", "getcwd", "(", ")", "from", "protect", ".", "mutation_calling", ".", "muse", "import", "process_muse_vcf", "from", "protec...
Merge the mutation calls for a single chromosome. :param str chrom: Chromosome to process :param dict mutations: dict of dicts of the various mutation caller names as keys, and a dict of per chromosome job store ids for vcfs as value :param dict univ_options: Dict of universal options used by al...
[ "Merge", "the", "mutation", "calls", "for", "a", "single", "chromosome", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/common.py#L74-L143
train
BD2KGenomics/protect
src/protect/mutation_calling/common.py
read_vcf
def read_vcf(vcf_file): """ Read a vcf file to a dict of lists. :param str vcf_file: Path to a vcf file. :return: dict of lists of vcf records :rtype: dict """ vcf_dict = [] with open(vcf_file, 'r') as invcf: for line in invcf: if line.startswith('#'): ...
python
def read_vcf(vcf_file): """ Read a vcf file to a dict of lists. :param str vcf_file: Path to a vcf file. :return: dict of lists of vcf records :rtype: dict """ vcf_dict = [] with open(vcf_file, 'r') as invcf: for line in invcf: if line.startswith('#'): ...
[ "def", "read_vcf", "(", "vcf_file", ")", ":", "vcf_dict", "=", "[", "]", "with", "open", "(", "vcf_file", ",", "'r'", ")", "as", "invcf", ":", "for", "line", "in", "invcf", ":", "if", "line", ".", "startswith", "(", "'#'", ")", ":", "continue", "li...
Read a vcf file to a dict of lists. :param str vcf_file: Path to a vcf file. :return: dict of lists of vcf records :rtype: dict
[ "Read", "a", "vcf", "file", "to", "a", "dict", "of", "lists", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/common.py#L146-L161
train
BD2KGenomics/protect
src/protect/mutation_calling/common.py
merge_perchrom_vcfs
def merge_perchrom_vcfs(job, perchrom_vcfs, tool_name, univ_options): """ Merge per-chromosome vcf files into a single genome level vcf. :param dict perchrom_vcfs: Dictionary with chromosome name as key and fsID of the corresponding vcf as value :param str tool_name: Name of the tool that ge...
python
def merge_perchrom_vcfs(job, perchrom_vcfs, tool_name, univ_options): """ Merge per-chromosome vcf files into a single genome level vcf. :param dict perchrom_vcfs: Dictionary with chromosome name as key and fsID of the corresponding vcf as value :param str tool_name: Name of the tool that ge...
[ "def", "merge_perchrom_vcfs", "(", "job", ",", "perchrom_vcfs", ",", "tool_name", ",", "univ_options", ")", ":", "work_dir", "=", "os", ".", "getcwd", "(", ")", "input_files", "=", "{", "''", ".", "join", "(", "[", "chrom", ",", "'.vcf'", "]", ")", ":"...
Merge per-chromosome vcf files into a single genome level vcf. :param dict perchrom_vcfs: Dictionary with chromosome name as key and fsID of the corresponding vcf as value :param str tool_name: Name of the tool that generated the vcfs :returns: fsID for the merged vcf :rtype: toil.fileStore....
[ "Merge", "per", "-", "chromosome", "vcf", "files", "into", "a", "single", "genome", "level", "vcf", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/common.py#L164-L192
train
BD2KGenomics/protect
src/protect/mutation_calling/common.py
unmerge
def unmerge(job, input_vcf, tool_name, chromosomes, tool_options, univ_options): """ Un-merge a vcf file into per-chromosome vcfs. :param str input_vcf: Input vcf :param str tool_name: The name of the mutation caller :param list chromosomes: List of chromosomes to retain :param dict tool_option...
python
def unmerge(job, input_vcf, tool_name, chromosomes, tool_options, univ_options): """ Un-merge a vcf file into per-chromosome vcfs. :param str input_vcf: Input vcf :param str tool_name: The name of the mutation caller :param list chromosomes: List of chromosomes to retain :param dict tool_option...
[ "def", "unmerge", "(", "job", ",", "input_vcf", ",", "tool_name", ",", "chromosomes", ",", "tool_options", ",", "univ_options", ")", ":", "work_dir", "=", "os", ".", "getcwd", "(", ")", "input_files", "=", "{", "'input.vcf'", ":", "input_vcf", ",", "'genom...
Un-merge a vcf file into per-chromosome vcfs. :param str input_vcf: Input vcf :param str tool_name: The name of the mutation caller :param list chromosomes: List of chromosomes to retain :param dict tool_options: Options specific to the mutation caller :param dict univ_options: Dict of universal op...
[ "Un", "-", "merge", "a", "vcf", "file", "into", "per", "-", "chromosome", "vcfs", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/mutation_calling/common.py#L195-L243
train
bkg/django-spillway
spillway/collections.py
as_feature
def as_feature(data): """Returns a Feature or FeatureCollection. Arguments: data -- Sequence or Mapping of Feature-like or FeatureCollection-like data """ if not isinstance(data, (Feature, FeatureCollection)): if is_featurelike(data): data = Feature(**data) elif has_feat...
python
def as_feature(data): """Returns a Feature or FeatureCollection. Arguments: data -- Sequence or Mapping of Feature-like or FeatureCollection-like data """ if not isinstance(data, (Feature, FeatureCollection)): if is_featurelike(data): data = Feature(**data) elif has_feat...
[ "def", "as_feature", "(", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "(", "Feature", ",", "FeatureCollection", ")", ")", ":", "if", "is_featurelike", "(", "data", ")", ":", "data", "=", "Feature", "(", "**", "data", ")", "elif", "...
Returns a Feature or FeatureCollection. Arguments: data -- Sequence or Mapping of Feature-like or FeatureCollection-like data
[ "Returns", "a", "Feature", "or", "FeatureCollection", "." ]
c488a62642430b005f1e0d4a19e160d8d5964b67
https://github.com/bkg/django-spillway/blob/c488a62642430b005f1e0d4a19e160d8d5964b67/spillway/collections.py#L9-L28
train
bkg/django-spillway
spillway/collections.py
has_layer
def has_layer(fcollection): """Returns true for a multi-layer dict of FeatureCollections.""" for val in six.viewvalues(fcollection): if has_features(val): return True return False
python
def has_layer(fcollection): """Returns true for a multi-layer dict of FeatureCollections.""" for val in six.viewvalues(fcollection): if has_features(val): return True return False
[ "def", "has_layer", "(", "fcollection", ")", ":", "for", "val", "in", "six", ".", "viewvalues", "(", "fcollection", ")", ":", "if", "has_features", "(", "val", ")", ":", "return", "True", "return", "False" ]
Returns true for a multi-layer dict of FeatureCollections.
[ "Returns", "true", "for", "a", "multi", "-", "layer", "dict", "of", "FeatureCollections", "." ]
c488a62642430b005f1e0d4a19e160d8d5964b67
https://github.com/bkg/django-spillway/blob/c488a62642430b005f1e0d4a19e160d8d5964b67/spillway/collections.py#L51-L56
train
BD2KGenomics/protect
src/protect/expression_profiling/rsem.py
wrap_rsem
def wrap_rsem(job, star_bams, univ_options, rsem_options): """ A wrapper for run_rsem using the results from run_star as input. :param dict star_bams: dict of results from star :param dict univ_options: Dict of universal options used by almost all tools :param dict rsem_options: Options specific to...
python
def wrap_rsem(job, star_bams, univ_options, rsem_options): """ A wrapper for run_rsem using the results from run_star as input. :param dict star_bams: dict of results from star :param dict univ_options: Dict of universal options used by almost all tools :param dict rsem_options: Options specific to...
[ "def", "wrap_rsem", "(", "job", ",", "star_bams", ",", "univ_options", ",", "rsem_options", ")", ":", "rsem", "=", "job", ".", "addChildJobFn", "(", "run_rsem", ",", "star_bams", "[", "'rna_transcriptome.bam'", "]", ",", "univ_options", ",", "rsem_options", ",...
A wrapper for run_rsem using the results from run_star as input. :param dict star_bams: dict of results from star :param dict univ_options: Dict of universal options used by almost all tools :param dict rsem_options: Options specific to rsem :return: Dict of gene- and isoform-level expression calls ...
[ "A", "wrapper", "for", "run_rsem", "using", "the", "results", "from", "run_star", "as", "input", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/expression_profiling/rsem.py#L36-L54
train
BD2KGenomics/protect
src/protect/expression_profiling/rsem.py
run_rsem
def run_rsem(job, rna_bam, univ_options, rsem_options): """ Run rsem on the input RNA bam. ARGUMENTS :param toil.fileStore.FileID rna_bam: fsID of a transcriptome bam generated by STAR :param dict univ_options: Dict of universal options used by almost all tools :param dict rsem_options: Options...
python
def run_rsem(job, rna_bam, univ_options, rsem_options): """ Run rsem on the input RNA bam. ARGUMENTS :param toil.fileStore.FileID rna_bam: fsID of a transcriptome bam generated by STAR :param dict univ_options: Dict of universal options used by almost all tools :param dict rsem_options: Options...
[ "def", "run_rsem", "(", "job", ",", "rna_bam", ",", "univ_options", ",", "rsem_options", ")", ":", "work_dir", "=", "os", ".", "getcwd", "(", ")", "input_files", "=", "{", "'star_transcriptome.bam'", ":", "rna_bam", ",", "'rsem_index.tar.gz'", ":", "rsem_optio...
Run rsem on the input RNA bam. ARGUMENTS :param toil.fileStore.FileID rna_bam: fsID of a transcriptome bam generated by STAR :param dict univ_options: Dict of universal options used by almost all tools :param dict rsem_options: Options specific to rsem :return: Dict of gene- and isoform-level expre...
[ "Run", "rsem", "on", "the", "input", "RNA", "bam", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/expression_profiling/rsem.py#L57-L95
train
idlesign/steampak
steampak/libsteam/resources/overlay.py
Overlay.activate
def activate(self, page=None): """Activates overlay with browser, optionally opened at a given page. :param str page: Overlay page alias (see OVERLAY_PAGE_*) or a custom URL. """ page = page or '' if '://' in page: self._iface.activate_overlay_url(page)...
python
def activate(self, page=None): """Activates overlay with browser, optionally opened at a given page. :param str page: Overlay page alias (see OVERLAY_PAGE_*) or a custom URL. """ page = page or '' if '://' in page: self._iface.activate_overlay_url(page)...
[ "def", "activate", "(", "self", ",", "page", "=", "None", ")", ":", "page", "=", "page", "or", "''", "if", "'://'", "in", "page", ":", "self", ".", "_iface", ".", "activate_overlay_url", "(", "page", ")", "else", ":", "self", ".", "_iface", ".", "a...
Activates overlay with browser, optionally opened at a given page. :param str page: Overlay page alias (see OVERLAY_PAGE_*) or a custom URL.
[ "Activates", "overlay", "with", "browser", "optionally", "opened", "at", "a", "given", "page", "." ]
cb3f2c737e272b0360802d947e388df7e34f50f3
https://github.com/idlesign/steampak/blob/cb3f2c737e272b0360802d947e388df7e34f50f3/steampak/libsteam/resources/overlay.py#L30-L43
train
drslump/pyshould
pyshould/dsl.py
any_of
def any_of(value, *args): """ At least one of the items in value should match """ if len(args): value = (value,) + args return ExpectationAny(value)
python
def any_of(value, *args): """ At least one of the items in value should match """ if len(args): value = (value,) + args return ExpectationAny(value)
[ "def", "any_of", "(", "value", ",", "*", "args", ")", ":", "if", "len", "(", "args", ")", ":", "value", "=", "(", "value", ",", ")", "+", "args", "return", "ExpectationAny", "(", "value", ")" ]
At least one of the items in value should match
[ "At", "least", "one", "of", "the", "items", "in", "value", "should", "match" ]
7210859d4c84cfbaa64f91b30c2a541aea788ddf
https://github.com/drslump/pyshould/blob/7210859d4c84cfbaa64f91b30c2a541aea788ddf/pyshould/dsl.py#L33-L39
train
drslump/pyshould
pyshould/dsl.py
all_of
def all_of(value, *args): """ All the items in value should match """ if len(args): value = (value,) + args return ExpectationAll(value)
python
def all_of(value, *args): """ All the items in value should match """ if len(args): value = (value,) + args return ExpectationAll(value)
[ "def", "all_of", "(", "value", ",", "*", "args", ")", ":", "if", "len", "(", "args", ")", ":", "value", "=", "(", "value", ",", ")", "+", "args", "return", "ExpectationAll", "(", "value", ")" ]
All the items in value should match
[ "All", "the", "items", "in", "value", "should", "match" ]
7210859d4c84cfbaa64f91b30c2a541aea788ddf
https://github.com/drslump/pyshould/blob/7210859d4c84cfbaa64f91b30c2a541aea788ddf/pyshould/dsl.py#L42-L48
train
drslump/pyshould
pyshould/dsl.py
none_of
def none_of(value, *args): """ None of the items in value should match """ if len(args): value = (value,) + args return ExpectationNone(value)
python
def none_of(value, *args): """ None of the items in value should match """ if len(args): value = (value,) + args return ExpectationNone(value)
[ "def", "none_of", "(", "value", ",", "*", "args", ")", ":", "if", "len", "(", "args", ")", ":", "value", "=", "(", "value", ",", ")", "+", "args", "return", "ExpectationNone", "(", "value", ")" ]
None of the items in value should match
[ "None", "of", "the", "items", "in", "value", "should", "match" ]
7210859d4c84cfbaa64f91b30c2a541aea788ddf
https://github.com/drslump/pyshould/blob/7210859d4c84cfbaa64f91b30c2a541aea788ddf/pyshould/dsl.py#L51-L57
train
BD2KGenomics/protect
src/protect/qc/rna.py
run_cutadapt
def run_cutadapt(job, fastqs, univ_options, cutadapt_options): """ Runs cutadapt on the input RNA fastq files. :param list fastqs: List of fsIDs for input an RNA-Seq fastq pair :param dict univ_options: Dict of universal options used by almost all tools :param dict cutadapt_options: Options specifi...
python
def run_cutadapt(job, fastqs, univ_options, cutadapt_options): """ Runs cutadapt on the input RNA fastq files. :param list fastqs: List of fsIDs for input an RNA-Seq fastq pair :param dict univ_options: Dict of universal options used by almost all tools :param dict cutadapt_options: Options specifi...
[ "def", "run_cutadapt", "(", "job", ",", "fastqs", ",", "univ_options", ",", "cutadapt_options", ")", ":", "work_dir", "=", "os", ".", "getcwd", "(", ")", "input_files", "=", "{", "'rna_1.fastq'", ":", "fastqs", "[", "0", "]", ",", "'rna_2.fastq'", ":", "...
Runs cutadapt on the input RNA fastq files. :param list fastqs: List of fsIDs for input an RNA-Seq fastq pair :param dict univ_options: Dict of universal options used by almost all tools :param dict cutadapt_options: Options specific to cutadapt :return: List of fsIDs of cutadapted fastqs :rtype: l...
[ "Runs", "cutadapt", "on", "the", "input", "RNA", "fastq", "files", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/qc/rna.py#L29-L64
train
inveniosoftware/invenio-access
examples/app.py
index
def index(): """Basic test view.""" identity = g.identity actions = {} for action in access.actions.values(): actions[action.value] = DynamicPermission(action).allows(identity) if current_user.is_anonymous: return render_template("invenio_access/open.html", ...
python
def index(): """Basic test view.""" identity = g.identity actions = {} for action in access.actions.values(): actions[action.value] = DynamicPermission(action).allows(identity) if current_user.is_anonymous: return render_template("invenio_access/open.html", ...
[ "def", "index", "(", ")", ":", "identity", "=", "g", ".", "identity", "actions", "=", "{", "}", "for", "action", "in", "access", ".", "actions", ".", "values", "(", ")", ":", "actions", "[", "action", ".", "value", "]", "=", "DynamicPermission", "(",...
Basic test view.
[ "Basic", "test", "view", "." ]
3b033a4bdc110eb2f7e9f08f0744a780884bfc80
https://github.com/inveniosoftware/invenio-access/blob/3b033a4bdc110eb2f7e9f08f0744a780884bfc80/examples/app.py#L109-L124
train
inveniosoftware/invenio-access
examples/app.py
role_admin
def role_admin(): """View only allowed to admin role.""" identity = g.identity actions = {} for action in access.actions.values(): actions[action.value] = DynamicPermission(action).allows(identity) message = 'You are opening a page requiring the "admin-access" permission' return render_...
python
def role_admin(): """View only allowed to admin role.""" identity = g.identity actions = {} for action in access.actions.values(): actions[action.value] = DynamicPermission(action).allows(identity) message = 'You are opening a page requiring the "admin-access" permission' return render_...
[ "def", "role_admin", "(", ")", ":", "identity", "=", "g", ".", "identity", "actions", "=", "{", "}", "for", "action", "in", "access", ".", "actions", ".", "values", "(", ")", ":", "actions", "[", "action", ".", "value", "]", "=", "DynamicPermission", ...
View only allowed to admin role.
[ "View", "only", "allowed", "to", "admin", "role", "." ]
3b033a4bdc110eb2f7e9f08f0744a780884bfc80
https://github.com/inveniosoftware/invenio-access/blob/3b033a4bdc110eb2f7e9f08f0744a780884bfc80/examples/app.py#L134-L145
train
BD2KGenomics/protect
src/protect/binding_prediction/common.py
read_fastas
def read_fastas(input_files): """ Read the tumor and normal fastas into a joint dict. :param dict input_files: A dict containing filename: filepath for T_ and N_ transgened files. :return: The read fastas in a dictionary of tuples :rtype: dict """ tumor_file = [y for x, y in input_files.ite...
python
def read_fastas(input_files): """ Read the tumor and normal fastas into a joint dict. :param dict input_files: A dict containing filename: filepath for T_ and N_ transgened files. :return: The read fastas in a dictionary of tuples :rtype: dict """ tumor_file = [y for x, y in input_files.ite...
[ "def", "read_fastas", "(", "input_files", ")", ":", "tumor_file", "=", "[", "y", "for", "x", ",", "y", "in", "input_files", ".", "items", "(", ")", "if", "x", ".", "startswith", "(", "'T'", ")", "]", "[", "0", "]", "normal_file", "=", "[", "y", "...
Read the tumor and normal fastas into a joint dict. :param dict input_files: A dict containing filename: filepath for T_ and N_ transgened files. :return: The read fastas in a dictionary of tuples :rtype: dict
[ "Read", "the", "tumor", "and", "normal", "fastas", "into", "a", "joint", "dict", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/binding_prediction/common.py#L140-L155
train
BD2KGenomics/protect
src/protect/binding_prediction/common.py
_read_fasta
def _read_fasta(fasta_file, output_dict): """ Read the peptide fasta into an existing dict. :param str fasta_file: The peptide file :param dict output_dict: The dict to appends results to. :return: output_dict :rtype: dict """ read_name = None with open(fasta_file, 'r') as f: ...
python
def _read_fasta(fasta_file, output_dict): """ Read the peptide fasta into an existing dict. :param str fasta_file: The peptide file :param dict output_dict: The dict to appends results to. :return: output_dict :rtype: dict """ read_name = None with open(fasta_file, 'r') as f: ...
[ "def", "_read_fasta", "(", "fasta_file", ",", "output_dict", ")", ":", "read_name", "=", "None", "with", "open", "(", "fasta_file", ",", "'r'", ")", "as", "f", ":", "for", "line", "in", "f", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "...
Read the peptide fasta into an existing dict. :param str fasta_file: The peptide file :param dict output_dict: The dict to appends results to. :return: output_dict :rtype: dict
[ "Read", "the", "peptide", "fasta", "into", "an", "existing", "dict", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/binding_prediction/common.py#L158-L178
train
BD2KGenomics/protect
src/protect/binding_prediction/common.py
_process_consensus_mhcii
def _process_consensus_mhcii(mhc_file, normal=False): """ Process the results from running IEDB MHCII binding predictions using the consensus method into a pandas dataframe. :param str mhc_file: Output file containing consensus mhcii:peptide binding predictions :param bool normal: Is this processin...
python
def _process_consensus_mhcii(mhc_file, normal=False): """ Process the results from running IEDB MHCII binding predictions using the consensus method into a pandas dataframe. :param str mhc_file: Output file containing consensus mhcii:peptide binding predictions :param bool normal: Is this processin...
[ "def", "_process_consensus_mhcii", "(", "mhc_file", ",", "normal", "=", "False", ")", ":", "core_col", "=", "None", "results", "=", "pandas", ".", "DataFrame", "(", "columns", "=", "[", "'allele'", ",", "'pept'", ",", "'tumor_pred'", ",", "'core'", "]", ")...
Process the results from running IEDB MHCII binding predictions using the consensus method into a pandas dataframe. :param str mhc_file: Output file containing consensus mhcii:peptide binding predictions :param bool normal: Is this processing the results of a normal? :return: Results in a tabular forma...
[ "Process", "the", "results", "from", "running", "IEDB", "MHCII", "binding", "predictions", "using", "the", "consensus", "method", "into", "a", "pandas", "dataframe", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/binding_prediction/common.py#L181-L221
train
BD2KGenomics/protect
src/protect/binding_prediction/common.py
_process_net_mhcii
def _process_net_mhcii(mhc_file, normal=False): """ Process the results from running NetMHCIIpan binding predictions into a pandas dataframe. :param str mhc_file: Output file containing netmhciipan mhcii:peptide binding predictions :param bool normal: Is this processing the results of a normal? :re...
python
def _process_net_mhcii(mhc_file, normal=False): """ Process the results from running NetMHCIIpan binding predictions into a pandas dataframe. :param str mhc_file: Output file containing netmhciipan mhcii:peptide binding predictions :param bool normal: Is this processing the results of a normal? :re...
[ "def", "_process_net_mhcii", "(", "mhc_file", ",", "normal", "=", "False", ")", ":", "results", "=", "pandas", ".", "DataFrame", "(", "columns", "=", "[", "'allele'", ",", "'pept'", ",", "'tumor_pred'", ",", "'core'", ",", "'peptide_name'", "]", ")", "with...
Process the results from running NetMHCIIpan binding predictions into a pandas dataframe. :param str mhc_file: Output file containing netmhciipan mhcii:peptide binding predictions :param bool normal: Is this processing the results of a normal? :return: Results in a tabular format :rtype: pandas.DataFra...
[ "Process", "the", "results", "from", "running", "NetMHCIIpan", "binding", "predictions", "into", "a", "pandas", "dataframe", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/binding_prediction/common.py#L253-L278
train
BD2KGenomics/protect
src/protect/binding_prediction/common.py
_process_mhci
def _process_mhci(mhc_file, normal=False): """ Process the results from running IEDB MHCI binding predictions into a pandas dataframe. :param str mhc_file: Output file containing netmhciipan mhci:peptide binding predictions :param bool normal: Is this processing the results of a normal? :return: Re...
python
def _process_mhci(mhc_file, normal=False): """ Process the results from running IEDB MHCI binding predictions into a pandas dataframe. :param str mhc_file: Output file containing netmhciipan mhci:peptide binding predictions :param bool normal: Is this processing the results of a normal? :return: Re...
[ "def", "_process_mhci", "(", "mhc_file", ",", "normal", "=", "False", ")", ":", "results", "=", "pandas", ".", "DataFrame", "(", "columns", "=", "[", "'allele'", ",", "'pept'", ",", "'tumor_pred'", ",", "'core'", "]", ")", "with", "open", "(", "mhc_file"...
Process the results from running IEDB MHCI binding predictions into a pandas dataframe. :param str mhc_file: Output file containing netmhciipan mhci:peptide binding predictions :param bool normal: Is this processing the results of a normal? :return: Results in a tabular format :rtype: pandas.DataFrame
[ "Process", "the", "results", "from", "running", "IEDB", "MHCI", "binding", "predictions", "into", "a", "pandas", "dataframe", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/binding_prediction/common.py#L281-L305
train
BD2KGenomics/protect
src/protect/binding_prediction/common.py
pept_diff
def pept_diff(p1, p2): """ Return the number of differences betweeen 2 peptides :param str p1: Peptide 1 :param str p2: Peptide 2 :return: The number of differences between the pepetides :rtype: int >>> pept_diff('ABCDE', 'ABCDF') 1 >>> pept_diff('ABCDE', 'ABDFE') 2 >>> pep...
python
def pept_diff(p1, p2): """ Return the number of differences betweeen 2 peptides :param str p1: Peptide 1 :param str p2: Peptide 2 :return: The number of differences between the pepetides :rtype: int >>> pept_diff('ABCDE', 'ABCDF') 1 >>> pept_diff('ABCDE', 'ABDFE') 2 >>> pep...
[ "def", "pept_diff", "(", "p1", ",", "p2", ")", ":", "if", "len", "(", "p1", ")", "!=", "len", "(", "p2", ")", ":", "return", "-", "1", "else", ":", "return", "sum", "(", "[", "p1", "[", "i", "]", "!=", "p2", "[", "i", "]", "for", "i", "in...
Return the number of differences betweeen 2 peptides :param str p1: Peptide 1 :param str p2: Peptide 2 :return: The number of differences between the pepetides :rtype: int >>> pept_diff('ABCDE', 'ABCDF') 1 >>> pept_diff('ABCDE', 'ABDFE') 2 >>> pept_diff('ABCDE', 'EDCBA') 4 ...
[ "Return", "the", "number", "of", "differences", "betweeen", "2", "peptides" ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/binding_prediction/common.py#L308-L329
train
BD2KGenomics/protect
src/protect/binding_prediction/common.py
print_mhc_peptide
def print_mhc_peptide(neoepitope_info, peptides, pepmap, outfile, netmhc=False): """ Accept data about one neoepitope from merge_mhc_peptide_calls and print it to outfile. This is a generic module to reduce code redundancy. :param pandas.core.frame neoepitope_info: object containing with allele, pept,...
python
def print_mhc_peptide(neoepitope_info, peptides, pepmap, outfile, netmhc=False): """ Accept data about one neoepitope from merge_mhc_peptide_calls and print it to outfile. This is a generic module to reduce code redundancy. :param pandas.core.frame neoepitope_info: object containing with allele, pept,...
[ "def", "print_mhc_peptide", "(", "neoepitope_info", ",", "peptides", ",", "pepmap", ",", "outfile", ",", "netmhc", "=", "False", ")", ":", "if", "netmhc", ":", "peptide_names", "=", "[", "neoepitope_info", ".", "peptide_name", "]", "else", ":", "peptide_names"...
Accept data about one neoepitope from merge_mhc_peptide_calls and print it to outfile. This is a generic module to reduce code redundancy. :param pandas.core.frame neoepitope_info: object containing with allele, pept, pred, core, normal_pept, normal_pred :param dict peptides: Dict of pepname: p...
[ "Accept", "data", "about", "one", "neoepitope", "from", "merge_mhc_peptide_calls", "and", "print", "it", "to", "outfile", ".", "This", "is", "a", "generic", "module", "to", "reduce", "code", "redundancy", "." ]
06310682c50dcf8917b912c8e551299ff7ee41ce
https://github.com/BD2KGenomics/protect/blob/06310682c50dcf8917b912c8e551299ff7ee41ce/src/protect/binding_prediction/common.py#L581-L615
train
rs/domcheck
domcheck/__init__.py
check
def check(domain, prefix, code, strategies='*'): """ Check the ownership of a domain by going thru a serie of strategies. If at least one strategy succeed, the domain is considered verified, and this methods returns true. The prefix is a fixed DNS safe string like "yourservice-domain-verification" ...
python
def check(domain, prefix, code, strategies='*'): """ Check the ownership of a domain by going thru a serie of strategies. If at least one strategy succeed, the domain is considered verified, and this methods returns true. The prefix is a fixed DNS safe string like "yourservice-domain-verification" ...
[ "def", "check", "(", "domain", ",", "prefix", ",", "code", ",", "strategies", "=", "'*'", ")", ":", "if", "strategies", "==", "'*'", "or", "'dns_txt'", "in", "strategies", ":", "if", "check_dns_txt", "(", "domain", ",", "prefix", ",", "code", ")", ":",...
Check the ownership of a domain by going thru a serie of strategies. If at least one strategy succeed, the domain is considered verified, and this methods returns true. The prefix is a fixed DNS safe string like "yourservice-domain-verification" and the code is a random value associated to this domain....
[ "Check", "the", "ownership", "of", "a", "domain", "by", "going", "thru", "a", "serie", "of", "strategies", ".", "If", "at", "least", "one", "strategy", "succeed", "the", "domain", "is", "considered", "verified", "and", "this", "methods", "returns", "true", ...
43e10c345320564a1236778e8577e2b8ef825925
https://github.com/rs/domcheck/blob/43e10c345320564a1236778e8577e2b8ef825925/domcheck/__init__.py#L6-L34
train
daxlab/Flask-Cache-Buster
flask_cache_buster/__init__.py
CacheBuster.register_cache_buster
def register_cache_buster(self, app, config=None): """ Register `app` in cache buster so that `url_for` adds a unique prefix to URLs generated for the `'static'` endpoint. Also make the app able to serve cache-busted static files. This allows setting long cache expiration values...
python
def register_cache_buster(self, app, config=None): """ Register `app` in cache buster so that `url_for` adds a unique prefix to URLs generated for the `'static'` endpoint. Also make the app able to serve cache-busted static files. This allows setting long cache expiration values...
[ "def", "register_cache_buster", "(", "self", ",", "app", ",", "config", "=", "None", ")", ":", "if", "not", "(", "config", "is", "None", "or", "isinstance", "(", "config", ",", "dict", ")", ")", ":", "raise", "ValueError", "(", "\"`config` must be an insta...
Register `app` in cache buster so that `url_for` adds a unique prefix to URLs generated for the `'static'` endpoint. Also make the app able to serve cache-busted static files. This allows setting long cache expiration values on static resources because whenever the resource changes, so ...
[ "Register", "app", "in", "cache", "buster", "so", "that", "url_for", "adds", "a", "unique", "prefix", "to", "URLs", "generated", "for", "the", "static", "endpoint", ".", "Also", "make", "the", "app", "able", "to", "serve", "cache", "-", "busted", "static",...
4c10bed9ab46020904df565a9c0014a7f2e4f6b3
https://github.com/daxlab/Flask-Cache-Buster/blob/4c10bed9ab46020904df565a9c0014a7f2e4f6b3/flask_cache_buster/__init__.py#L29-L93
train
theherk/figgypy
figgypy/utils.py
env_or_default
def env_or_default(var, default=None): """Get environment variable or provide default. Args: var (str): environment variable to search for default (optional(str)): default to return """ if var in os.environ: return os.environ[var] return default
python
def env_or_default(var, default=None): """Get environment variable or provide default. Args: var (str): environment variable to search for default (optional(str)): default to return """ if var in os.environ: return os.environ[var] return default
[ "def", "env_or_default", "(", "var", ",", "default", "=", "None", ")", ":", "if", "var", "in", "os", ".", "environ", ":", "return", "os", ".", "environ", "[", "var", "]", "return", "default" ]
Get environment variable or provide default. Args: var (str): environment variable to search for default (optional(str)): default to return
[ "Get", "environment", "variable", "or", "provide", "default", "." ]
324d1b281a8df20a26b92f42bf7fda0cca892116
https://github.com/theherk/figgypy/blob/324d1b281a8df20a26b92f42bf7fda0cca892116/figgypy/utils.py#L11-L20
train
theherk/figgypy
figgypy/utils.py
kms_encrypt
def kms_encrypt(value, key, aws_config=None): """Encrypt and value with KMS key. Args: value (str): value to encrypt key (str): key id or alias aws_config (optional[dict]): aws credentials dict of arguments passed into boto3 session example: aws_c...
python
def kms_encrypt(value, key, aws_config=None): """Encrypt and value with KMS key. Args: value (str): value to encrypt key (str): key id or alias aws_config (optional[dict]): aws credentials dict of arguments passed into boto3 session example: aws_c...
[ "def", "kms_encrypt", "(", "value", ",", "key", ",", "aws_config", "=", "None", ")", ":", "aws_config", "=", "aws_config", "or", "{", "}", "aws", "=", "boto3", ".", "session", ".", "Session", "(", "**", "aws_config", ")", "client", "=", "aws", ".", "...
Encrypt and value with KMS key. Args: value (str): value to encrypt key (str): key id or alias aws_config (optional[dict]): aws credentials dict of arguments passed into boto3 session example: aws_creds = {'aws_access_key_id': aws_access_key_id, ...
[ "Encrypt", "and", "value", "with", "KMS", "key", "." ]
324d1b281a8df20a26b92f42bf7fda0cca892116
https://github.com/theherk/figgypy/blob/324d1b281a8df20a26b92f42bf7fda0cca892116/figgypy/utils.py#L23-L44
train
theherk/figgypy
figgypy/__init__.py
get_value
def get_value(*args, **kwargs): """Get from config object by exposing Config.get_value method. dict.get() method on Config.values """ global _config if _config is None: raise ValueError('configuration not set; must run figgypy.set_config first') return _config.get_value(*args, **kwargs)
python
def get_value(*args, **kwargs): """Get from config object by exposing Config.get_value method. dict.get() method on Config.values """ global _config if _config is None: raise ValueError('configuration not set; must run figgypy.set_config first') return _config.get_value(*args, **kwargs)
[ "def", "get_value", "(", "*", "args", ",", "**", "kwargs", ")", ":", "global", "_config", "if", "_config", "is", "None", ":", "raise", "ValueError", "(", "'configuration not set; must run figgypy.set_config first'", ")", "return", "_config", ".", "get_value", "(",...
Get from config object by exposing Config.get_value method. dict.get() method on Config.values
[ "Get", "from", "config", "object", "by", "exposing", "Config", ".", "get_value", "method", "." ]
324d1b281a8df20a26b92f42bf7fda0cca892116
https://github.com/theherk/figgypy/blob/324d1b281a8df20a26b92f42bf7fda0cca892116/figgypy/__init__.py#L27-L35
train
theherk/figgypy
figgypy/__init__.py
set_value
def set_value(*args, **kwargs): """Set value in the global Config object.""" global _config if _config is None: raise ValueError('configuration not set; must run figgypy.set_config first') return _config.set_value(*args, **kwargs)
python
def set_value(*args, **kwargs): """Set value in the global Config object.""" global _config if _config is None: raise ValueError('configuration not set; must run figgypy.set_config first') return _config.set_value(*args, **kwargs)
[ "def", "set_value", "(", "*", "args", ",", "**", "kwargs", ")", ":", "global", "_config", "if", "_config", "is", "None", ":", "raise", "ValueError", "(", "'configuration not set; must run figgypy.set_config first'", ")", "return", "_config", ".", "set_value", "(",...
Set value in the global Config object.
[ "Set", "value", "in", "the", "global", "Config", "object", "." ]
324d1b281a8df20a26b92f42bf7fda0cca892116
https://github.com/theherk/figgypy/blob/324d1b281a8df20a26b92f42bf7fda0cca892116/figgypy/__init__.py#L73-L78
train
Grk0/python-libconf
libconf.py
decode_escapes
def decode_escapes(s): '''Unescape libconfig string literals''' def decode_match(match): return codecs.decode(match.group(0), 'unicode-escape') return ESCAPE_SEQUENCE_RE.sub(decode_match, s)
python
def decode_escapes(s): '''Unescape libconfig string literals''' def decode_match(match): return codecs.decode(match.group(0), 'unicode-escape') return ESCAPE_SEQUENCE_RE.sub(decode_match, s)
[ "def", "decode_escapes", "(", "s", ")", ":", "def", "decode_match", "(", "match", ")", ":", "return", "codecs", ".", "decode", "(", "match", ".", "group", "(", "0", ")", ",", "'unicode-escape'", ")", "return", "ESCAPE_SEQUENCE_RE", ".", "sub", "(", "deco...
Unescape libconfig string literals
[ "Unescape", "libconfig", "string", "literals" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L50-L55
train
Grk0/python-libconf
libconf.py
loads
def loads(string, filename=None, includedir=''): '''Load the contents of ``string`` to a Python object The returned object is a subclass of ``dict`` that exposes string keys as attributes as well. Example: >>> config = libconf.loads('window: { title: "libconfig example"; };') >>> conf...
python
def loads(string, filename=None, includedir=''): '''Load the contents of ``string`` to a Python object The returned object is a subclass of ``dict`` that exposes string keys as attributes as well. Example: >>> config = libconf.loads('window: { title: "libconfig example"; };') >>> conf...
[ "def", "loads", "(", "string", ",", "filename", "=", "None", ",", "includedir", "=", "''", ")", ":", "try", ":", "f", "=", "io", ".", "StringIO", "(", "string", ")", "except", "TypeError", ":", "raise", "TypeError", "(", "\"libconf.loads() input string mus...
Load the contents of ``string`` to a Python object The returned object is a subclass of ``dict`` that exposes string keys as attributes as well. Example: >>> config = libconf.loads('window: { title: "libconfig example"; };') >>> config['window']['title'] 'libconfig example' ...
[ "Load", "the", "contents", "of", "string", "to", "a", "Python", "object" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L501-L521
train
Grk0/python-libconf
libconf.py
dump_string
def dump_string(s): '''Stringize ``s``, adding double quotes and escaping as necessary Backslash escape backslashes, double quotes, ``\f``, ``\n``, ``\r``, and ``\t``. Escape all remaining unprintable characters in ``\xFF``-style. The returned string will be surrounded by double quotes. ''' s ...
python
def dump_string(s): '''Stringize ``s``, adding double quotes and escaping as necessary Backslash escape backslashes, double quotes, ``\f``, ``\n``, ``\r``, and ``\t``. Escape all remaining unprintable characters in ``\xFF``-style. The returned string will be surrounded by double quotes. ''' s ...
[ "def", "dump_string", "(", "s", ")", ":", "s", "=", "(", "s", ".", "replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ")", ".", "replace", "(", "'\"'", ",", "'\\\\\"'", ")", ".", "replace", "(", "'\\f'", ",", "r'\\f'", ")", ".", "replace", "(", "'\\n'", ...
Stringize ``s``, adding double quotes and escaping as necessary Backslash escape backslashes, double quotes, ``\f``, ``\n``, ``\r``, and ``\t``. Escape all remaining unprintable characters in ``\xFF``-style. The returned string will be surrounded by double quotes.
[ "Stringize", "s", "adding", "double", "quotes", "and", "escaping", "as", "necessary" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L555-L572
train
Grk0/python-libconf
libconf.py
get_dump_type
def get_dump_type(value): '''Get the libconfig datatype of a value Return values: ``'d'`` (dict), ``'l'`` (list), ``'a'`` (array), ``'i'`` (integer), ``'i64'`` (long integer), ``'b'`` (bool), ``'f'`` (float), or ``'s'`` (string). Produces the proper type for LibconfList, LibconfArray, LibconfInt64...
python
def get_dump_type(value): '''Get the libconfig datatype of a value Return values: ``'d'`` (dict), ``'l'`` (list), ``'a'`` (array), ``'i'`` (integer), ``'i64'`` (long integer), ``'b'`` (bool), ``'f'`` (float), or ``'s'`` (string). Produces the proper type for LibconfList, LibconfArray, LibconfInt64...
[ "def", "get_dump_type", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "return", "'d'", "if", "isinstance", "(", "value", ",", "tuple", ")", ":", "return", "'l'", "if", "isinstance", "(", "value", ",", "list", ")", "...
Get the libconfig datatype of a value Return values: ``'d'`` (dict), ``'l'`` (list), ``'a'`` (array), ``'i'`` (integer), ``'i64'`` (long integer), ``'b'`` (bool), ``'f'`` (float), or ``'s'`` (string). Produces the proper type for LibconfList, LibconfArray, LibconfInt64 instances.
[ "Get", "the", "libconfig", "datatype", "of", "a", "value" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L575-L606
train
Grk0/python-libconf
libconf.py
get_array_value_dtype
def get_array_value_dtype(lst): '''Return array value type, raise ConfigSerializeError for invalid arrays Libconfig arrays must only contain scalar values and all elements must be of the same libconfig data type. Raises ConfigSerializeError if these invariants are not met. Returns the value type o...
python
def get_array_value_dtype(lst): '''Return array value type, raise ConfigSerializeError for invalid arrays Libconfig arrays must only contain scalar values and all elements must be of the same libconfig data type. Raises ConfigSerializeError if these invariants are not met. Returns the value type o...
[ "def", "get_array_value_dtype", "(", "lst", ")", ":", "array_value_type", "=", "None", "for", "value", "in", "lst", ":", "dtype", "=", "get_dump_type", "(", "value", ")", "if", "dtype", "not", "in", "{", "'b'", ",", "'i'", ",", "'i64'", ",", "'f'", ","...
Return array value type, raise ConfigSerializeError for invalid arrays Libconfig arrays must only contain scalar values and all elements must be of the same libconfig data type. Raises ConfigSerializeError if these invariants are not met. Returns the value type of the array. If an array contains both ...
[ "Return", "array", "value", "type", "raise", "ConfigSerializeError", "for", "invalid", "arrays" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L609-L646
train
Grk0/python-libconf
libconf.py
dump_value
def dump_value(key, value, f, indent=0): '''Save a value of any libconfig type This function serializes takes ``key`` and ``value`` and serializes them into ``f``. If ``key`` is ``None``, a list-style output is produced. Otherwise, output has ``key = value`` format. ''' spaces = ' ' * indent ...
python
def dump_value(key, value, f, indent=0): '''Save a value of any libconfig type This function serializes takes ``key`` and ``value`` and serializes them into ``f``. If ``key`` is ``None``, a list-style output is produced. Otherwise, output has ``key = value`` format. ''' spaces = ' ' * indent ...
[ "def", "dump_value", "(", "key", ",", "value", ",", "f", ",", "indent", "=", "0", ")", ":", "spaces", "=", "' '", "*", "indent", "if", "key", "is", "None", ":", "key_prefix", "=", "''", "key_prefix_nl", "=", "''", "else", ":", "key_prefix", "=", "k...
Save a value of any libconfig type This function serializes takes ``key`` and ``value`` and serializes them into ``f``. If ``key`` is ``None``, a list-style output is produced. Otherwise, output has ``key = value`` format.
[ "Save", "a", "value", "of", "any", "libconfig", "type" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L649-L692
train
Grk0/python-libconf
libconf.py
dump_collection
def dump_collection(cfg, f, indent=0): '''Save a collection of attributes''' for i, value in enumerate(cfg): dump_value(None, value, f, indent) if i < len(cfg) - 1: f.write(u',\n')
python
def dump_collection(cfg, f, indent=0): '''Save a collection of attributes''' for i, value in enumerate(cfg): dump_value(None, value, f, indent) if i < len(cfg) - 1: f.write(u',\n')
[ "def", "dump_collection", "(", "cfg", ",", "f", ",", "indent", "=", "0", ")", ":", "for", "i", ",", "value", "in", "enumerate", "(", "cfg", ")", ":", "dump_value", "(", "None", ",", "value", ",", "f", ",", "indent", ")", "if", "i", "<", "len", ...
Save a collection of attributes
[ "Save", "a", "collection", "of", "attributes" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L695-L701
train
Grk0/python-libconf
libconf.py
dump_dict
def dump_dict(cfg, f, indent=0): '''Save a dictionary of attributes''' for key in cfg: if not isstr(key): raise ConfigSerializeError("Dict keys must be strings: %r" % (key,)) dump_value(key, cfg[key], f, indent) f.write(u';\n')
python
def dump_dict(cfg, f, indent=0): '''Save a dictionary of attributes''' for key in cfg: if not isstr(key): raise ConfigSerializeError("Dict keys must be strings: %r" % (key,)) dump_value(key, cfg[key], f, indent) f.write(u';\n')
[ "def", "dump_dict", "(", "cfg", ",", "f", ",", "indent", "=", "0", ")", ":", "for", "key", "in", "cfg", ":", "if", "not", "isstr", "(", "key", ")", ":", "raise", "ConfigSerializeError", "(", "\"Dict keys must be strings: %r\"", "%", "(", "key", ",", ")...
Save a dictionary of attributes
[ "Save", "a", "dictionary", "of", "attributes" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L704-L712
train
Grk0/python-libconf
libconf.py
dumps
def dumps(cfg): '''Serialize ``cfg`` into a libconfig-formatted ``str`` ``cfg`` must be a ``dict`` with ``str`` keys and libconf-supported values (numbers, strings, booleans, possibly nested dicts, lists, and tuples). Returns the formatted string. ''' str_file = io.StringIO() dump(cfg, st...
python
def dumps(cfg): '''Serialize ``cfg`` into a libconfig-formatted ``str`` ``cfg`` must be a ``dict`` with ``str`` keys and libconf-supported values (numbers, strings, booleans, possibly nested dicts, lists, and tuples). Returns the formatted string. ''' str_file = io.StringIO() dump(cfg, st...
[ "def", "dumps", "(", "cfg", ")", ":", "str_file", "=", "io", ".", "StringIO", "(", ")", "dump", "(", "cfg", ",", "str_file", ")", "return", "str_file", ".", "getvalue", "(", ")" ]
Serialize ``cfg`` into a libconfig-formatted ``str`` ``cfg`` must be a ``dict`` with ``str`` keys and libconf-supported values (numbers, strings, booleans, possibly nested dicts, lists, and tuples). Returns the formatted string.
[ "Serialize", "cfg", "into", "a", "libconfig", "-", "formatted", "str" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L715-L726
train
Grk0/python-libconf
libconf.py
dump
def dump(cfg, f): '''Serialize ``cfg`` as a libconfig-formatted stream into ``f`` ``cfg`` must be a ``dict`` with ``str`` keys and libconf-supported values (numbers, strings, booleans, possibly nested dicts, lists, and tuples). ``f`` must be a ``file``-like object with a ``write()`` method. ''' ...
python
def dump(cfg, f): '''Serialize ``cfg`` as a libconfig-formatted stream into ``f`` ``cfg`` must be a ``dict`` with ``str`` keys and libconf-supported values (numbers, strings, booleans, possibly nested dicts, lists, and tuples). ``f`` must be a ``file``-like object with a ``write()`` method. ''' ...
[ "def", "dump", "(", "cfg", ",", "f", ")", ":", "if", "not", "isinstance", "(", "cfg", ",", "dict", ")", ":", "raise", "ConfigSerializeError", "(", "'dump() requires a dict as input, not %r of type %r'", "%", "(", "cfg", ",", "type", "(", "cfg", ")", ")", "...
Serialize ``cfg`` as a libconfig-formatted stream into ``f`` ``cfg`` must be a ``dict`` with ``str`` keys and libconf-supported values (numbers, strings, booleans, possibly nested dicts, lists, and tuples). ``f`` must be a ``file``-like object with a ``write()`` method.
[ "Serialize", "cfg", "as", "a", "libconfig", "-", "formatted", "stream", "into", "f" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L729-L743
train
Grk0/python-libconf
libconf.py
Tokenizer.tokenize
def tokenize(self, string): '''Yield tokens from the input string or throw ConfigParseError''' pos = 0 while pos < len(string): m = SKIP_RE.match(string, pos=pos) if m: skip_lines = m.group(0).split('\n') if len(skip_lines) > 1: ...
python
def tokenize(self, string): '''Yield tokens from the input string or throw ConfigParseError''' pos = 0 while pos < len(string): m = SKIP_RE.match(string, pos=pos) if m: skip_lines = m.group(0).split('\n') if len(skip_lines) > 1: ...
[ "def", "tokenize", "(", "self", ",", "string", ")", ":", "pos", "=", "0", "while", "pos", "<", "len", "(", "string", ")", ":", "m", "=", "SKIP_RE", ".", "match", "(", "string", ",", "pos", "=", "pos", ")", "if", "m", ":", "skip_lines", "=", "m"...
Yield tokens from the input string or throw ConfigParseError
[ "Yield", "tokens", "from", "the", "input", "string", "or", "throw", "ConfigParseError" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L178-L206
train
Grk0/python-libconf
libconf.py
TokenStream.from_file
def from_file(cls, f, filename=None, includedir='', seenfiles=None): '''Create a token stream by reading an input file Read tokens from `f`. If an include directive ('@include "file.cfg"') is found, read its contents as well. The `filename` argument is used for error messages and to de...
python
def from_file(cls, f, filename=None, includedir='', seenfiles=None): '''Create a token stream by reading an input file Read tokens from `f`. If an include directive ('@include "file.cfg"') is found, read its contents as well. The `filename` argument is used for error messages and to de...
[ "def", "from_file", "(", "cls", ",", "f", ",", "filename", "=", "None", ",", "includedir", "=", "''", ",", "seenfiles", "=", "None", ")", ":", "if", "filename", "is", "None", ":", "filename", "=", "getattr", "(", "f", ",", "'name'", ",", "'<unknown>'...
Create a token stream by reading an input file Read tokens from `f`. If an include directive ('@include "file.cfg"') is found, read its contents as well. The `filename` argument is used for error messages and to detect circular imports. ``includedir`` sets the lookup directory for incl...
[ "Create", "a", "token", "stream", "by", "reading", "an", "input", "file" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L224-L273
train
Grk0/python-libconf
libconf.py
TokenStream.error
def error(self, msg): '''Raise a ConfigParseError at the current input position''' if self.finished(): raise ConfigParseError("Unexpected end of input; %s" % (msg,)) else: t = self.peek() raise ConfigParseError("Unexpected token %s; %s" % (t, msg))
python
def error(self, msg): '''Raise a ConfigParseError at the current input position''' if self.finished(): raise ConfigParseError("Unexpected end of input; %s" % (msg,)) else: t = self.peek() raise ConfigParseError("Unexpected token %s; %s" % (t, msg))
[ "def", "error", "(", "self", ",", "msg", ")", ":", "if", "self", ".", "finished", "(", ")", ":", "raise", "ConfigParseError", "(", "\"Unexpected end of input; %s\"", "%", "(", "msg", ",", ")", ")", "else", ":", "t", "=", "self", ".", "peek", "(", ")"...
Raise a ConfigParseError at the current input position
[ "Raise", "a", "ConfigParseError", "at", "the", "current", "input", "position" ]
9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4
https://github.com/Grk0/python-libconf/blob/9c4cf5f56d56ebbc1fe0e1596807218b7d5d5da4/libconf.py#L321-L327
train
FulcrumTechnologies/pyconfluence
pyconfluence/api.py
load_variables
def load_variables(): """Load variables from environment variables.""" if (not os.environ.get("PYCONFLUENCE_TOKEN") or not os.environ.get("PYCONFLUENCE_USER") or not os.environ.get("PYCONFLUENCE_ORG")): print ("One or more pyconfluence environment variables are not set. " ...
python
def load_variables(): """Load variables from environment variables.""" if (not os.environ.get("PYCONFLUENCE_TOKEN") or not os.environ.get("PYCONFLUENCE_USER") or not os.environ.get("PYCONFLUENCE_ORG")): print ("One or more pyconfluence environment variables are not set. " ...
[ "def", "load_variables", "(", ")", ":", "if", "(", "not", "os", ".", "environ", ".", "get", "(", "\"PYCONFLUENCE_TOKEN\"", ")", "or", "not", "os", ".", "environ", ".", "get", "(", "\"PYCONFLUENCE_USER\"", ")", "or", "not", "os", ".", "environ", ".", "g...
Load variables from environment variables.
[ "Load", "variables", "from", "environment", "variables", "." ]
a999726dbc1cbdd3d9062234698eeae799ce84ce
https://github.com/FulcrumTechnologies/pyconfluence/blob/a999726dbc1cbdd3d9062234698eeae799ce84ce/pyconfluence/api.py#L21-L36
train
FulcrumTechnologies/pyconfluence
pyconfluence/api.py
rest
def rest(url, req="GET", data=None): """Main function to be called from this module. send a request using method 'req' and to the url. the _rest() function will add the base_url to this, so 'url' should be something like '/ips'. """ load_variables() return _rest(base_url + url, req, data)
python
def rest(url, req="GET", data=None): """Main function to be called from this module. send a request using method 'req' and to the url. the _rest() function will add the base_url to this, so 'url' should be something like '/ips'. """ load_variables() return _rest(base_url + url, req, data)
[ "def", "rest", "(", "url", ",", "req", "=", "\"GET\"", ",", "data", "=", "None", ")", ":", "load_variables", "(", ")", "return", "_rest", "(", "base_url", "+", "url", ",", "req", ",", "data", ")" ]
Main function to be called from this module. send a request using method 'req' and to the url. the _rest() function will add the base_url to this, so 'url' should be something like '/ips'.
[ "Main", "function", "to", "be", "called", "from", "this", "module", "." ]
a999726dbc1cbdd3d9062234698eeae799ce84ce
https://github.com/FulcrumTechnologies/pyconfluence/blob/a999726dbc1cbdd3d9062234698eeae799ce84ce/pyconfluence/api.py#L39-L47
train
FulcrumTechnologies/pyconfluence
pyconfluence/api.py
_rest
def _rest(url, req, data=None): """Send a rest rest request to the server.""" if url.upper().startswith("HTTPS"): print("Secure connection required: Please use HTTPS or https") return "" req = req.upper() if req != "GET" and req != "PUT" and req != "POST" and req != "DELETE": re...
python
def _rest(url, req, data=None): """Send a rest rest request to the server.""" if url.upper().startswith("HTTPS"): print("Secure connection required: Please use HTTPS or https") return "" req = req.upper() if req != "GET" and req != "PUT" and req != "POST" and req != "DELETE": re...
[ "def", "_rest", "(", "url", ",", "req", ",", "data", "=", "None", ")", ":", "if", "url", ".", "upper", "(", ")", ".", "startswith", "(", "\"HTTPS\"", ")", ":", "print", "(", "\"Secure connection required: Please use HTTPS or https\"", ")", "return", "\"\"", ...
Send a rest rest request to the server.
[ "Send", "a", "rest", "rest", "request", "to", "the", "server", "." ]
a999726dbc1cbdd3d9062234698eeae799ce84ce
https://github.com/FulcrumTechnologies/pyconfluence/blob/a999726dbc1cbdd3d9062234698eeae799ce84ce/pyconfluence/api.py#L50-L64
train
FulcrumTechnologies/pyconfluence
pyconfluence/api.py
_api_action
def _api_action(url, req, data=None): """Take action based on what kind of request is needed.""" requisite_headers = {'Accept': 'application/json', 'Content-Type': 'application/json'} auth = (user, token) if req == "GET": response = requests.get(url, headers=requisite_h...
python
def _api_action(url, req, data=None): """Take action based on what kind of request is needed.""" requisite_headers = {'Accept': 'application/json', 'Content-Type': 'application/json'} auth = (user, token) if req == "GET": response = requests.get(url, headers=requisite_h...
[ "def", "_api_action", "(", "url", ",", "req", ",", "data", "=", "None", ")", ":", "requisite_headers", "=", "{", "'Accept'", ":", "'application/json'", ",", "'Content-Type'", ":", "'application/json'", "}", "auth", "=", "(", "user", ",", "token", ")", "if"...
Take action based on what kind of request is needed.
[ "Take", "action", "based", "on", "what", "kind", "of", "request", "is", "needed", "." ]
a999726dbc1cbdd3d9062234698eeae799ce84ce
https://github.com/FulcrumTechnologies/pyconfluence/blob/a999726dbc1cbdd3d9062234698eeae799ce84ce/pyconfluence/api.py#L67-L84
train
kstaniek/condoor
condoor/patterns.py
PatternManager._platform_patterns
def _platform_patterns(self, platform='generic', compiled=False): """Return all the patterns for specific platform.""" patterns = self._dict_compiled.get(platform, None) if compiled else self._dict_text.get(platform, None) if patterns is None: raise KeyError("Unknown platform: {}".fo...
python
def _platform_patterns(self, platform='generic', compiled=False): """Return all the patterns for specific platform.""" patterns = self._dict_compiled.get(platform, None) if compiled else self._dict_text.get(platform, None) if patterns is None: raise KeyError("Unknown platform: {}".fo...
[ "def", "_platform_patterns", "(", "self", ",", "platform", "=", "'generic'", ",", "compiled", "=", "False", ")", ":", "patterns", "=", "self", ".", "_dict_compiled", ".", "get", "(", "platform", ",", "None", ")", "if", "compiled", "else", "self", ".", "_...
Return all the patterns for specific platform.
[ "Return", "all", "the", "patterns", "for", "specific", "platform", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/patterns.py#L56-L61
train
kstaniek/condoor
condoor/patterns.py
PatternManager.pattern
def pattern(self, platform, key, compiled=True): """Return the pattern defined by the key string specific to the platform. :param platform: :param key: :param compiled: :return: Pattern string or RE object. """ patterns = self._platform_patterns(platform, compile...
python
def pattern(self, platform, key, compiled=True): """Return the pattern defined by the key string specific to the platform. :param platform: :param key: :param compiled: :return: Pattern string or RE object. """ patterns = self._platform_patterns(platform, compile...
[ "def", "pattern", "(", "self", ",", "platform", ",", "key", ",", "compiled", "=", "True", ")", ":", "patterns", "=", "self", ".", "_platform_patterns", "(", "platform", ",", "compiled", "=", "compiled", ")", "pattern", "=", "patterns", ".", "get", "(", ...
Return the pattern defined by the key string specific to the platform. :param platform: :param key: :param compiled: :return: Pattern string or RE object.
[ "Return", "the", "pattern", "defined", "by", "the", "key", "string", "specific", "to", "the", "platform", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/patterns.py#L76-L90
train
kstaniek/condoor
condoor/patterns.py
PatternManager.description
def description(self, platform, key): """Return the patter description.""" patterns = self._dict_dscr.get(platform, None) description = patterns.get(key, None) return description
python
def description(self, platform, key): """Return the patter description.""" patterns = self._dict_dscr.get(platform, None) description = patterns.get(key, None) return description
[ "def", "description", "(", "self", ",", "platform", ",", "key", ")", ":", "patterns", "=", "self", ".", "_dict_dscr", ".", "get", "(", "platform", ",", "None", ")", "description", "=", "patterns", ".", "get", "(", "key", ",", "None", ")", "return", "...
Return the patter description.
[ "Return", "the", "patter", "description", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/patterns.py#L92-L96
train
kstaniek/condoor
condoor/patterns.py
PatternManager.platform
def platform(self, with_prompt, platforms=None): """Return the platform name based on the prompt matching.""" if platforms is None: platforms = self._dict['generic']['prompt_detection'] for platform in platforms: pattern = self.pattern(platform, 'prompt') res...
python
def platform(self, with_prompt, platforms=None): """Return the platform name based on the prompt matching.""" if platforms is None: platforms = self._dict['generic']['prompt_detection'] for platform in platforms: pattern = self.pattern(platform, 'prompt') res...
[ "def", "platform", "(", "self", ",", "with_prompt", ",", "platforms", "=", "None", ")", ":", "if", "platforms", "is", "None", ":", "platforms", "=", "self", ".", "_dict", "[", "'generic'", "]", "[", "'prompt_detection'", "]", "for", "platform", "in", "pl...
Return the platform name based on the prompt matching.
[ "Return", "the", "platform", "name", "based", "on", "the", "prompt", "matching", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/patterns.py#L98-L108
train
kstaniek/condoor
condoor/drivers/Calvados.py
Driver.after_connect
def after_connect(self): """Execute after connect.""" # TODO: check if this works. show_users = self.device.send("show users", timeout=120) result = re.search(pattern_manager.pattern(self.platform, 'connected_locally'), show_users) if result: self.log('Locally connect...
python
def after_connect(self): """Execute after connect.""" # TODO: check if this works. show_users = self.device.send("show users", timeout=120) result = re.search(pattern_manager.pattern(self.platform, 'connected_locally'), show_users) if result: self.log('Locally connect...
[ "def", "after_connect", "(", "self", ")", ":", "show_users", "=", "self", ".", "device", ".", "send", "(", "\"show users\"", ",", "timeout", "=", "120", ")", "result", "=", "re", ".", "search", "(", "pattern_manager", ".", "pattern", "(", "self", ".", ...
Execute after connect.
[ "Execute", "after", "connect", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/Calvados.py#L47-L56
train
kstaniek/condoor
condoor/drivers/jumphost.py
Driver.get_hostname_text
def get_hostname_text(self): """Return hostname information from the Unix host.""" # FIXME: fix it, too complex logic try: hostname_text = self.device.send('hostname', timeout=10) if hostname_text: self.device.hostname = hostname_text.splitlines()[0] ...
python
def get_hostname_text(self): """Return hostname information from the Unix host.""" # FIXME: fix it, too complex logic try: hostname_text = self.device.send('hostname', timeout=10) if hostname_text: self.device.hostname = hostname_text.splitlines()[0] ...
[ "def", "get_hostname_text", "(", "self", ")", ":", "try", ":", "hostname_text", "=", "self", ".", "device", ".", "send", "(", "'hostname'", ",", "timeout", "=", "10", ")", "if", "hostname_text", ":", "self", ".", "device", ".", "hostname", "=", "hostname...
Return hostname information from the Unix host.
[ "Return", "hostname", "information", "from", "the", "Unix", "host", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/drivers/jumphost.py#L35-L45
train
theherk/figgypy
figgypy/config.py
Config._find_file
def _find_file(f): """Find a config file if possible.""" if os.path.isabs(f): return f else: for d in Config._dirs: _f = os.path.join(d, f) if os.path.isfile(_f): return _f raise FiggypyError( ...
python
def _find_file(f): """Find a config file if possible.""" if os.path.isabs(f): return f else: for d in Config._dirs: _f = os.path.join(d, f) if os.path.isfile(_f): return _f raise FiggypyError( ...
[ "def", "_find_file", "(", "f", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "f", ")", ":", "return", "f", "else", ":", "for", "d", "in", "Config", ".", "_dirs", ":", "_f", "=", "os", ".", "path", ".", "join", "(", "d", ",", "f", ")...
Find a config file if possible.
[ "Find", "a", "config", "file", "if", "possible", "." ]
324d1b281a8df20a26b92f42bf7fda0cca892116
https://github.com/theherk/figgypy/blob/324d1b281a8df20a26b92f42bf7fda0cca892116/figgypy/config.py#L82-L94
train
theherk/figgypy
figgypy/config.py
Config._load_file
def _load_file(self, f): """Get values from config file""" try: with open(f, 'r') as _fo: _seria_in = seria.load(_fo) _y = _seria_in.dump('yaml') except IOError: raise FiggypyError("could not open configuration file") self.values.up...
python
def _load_file(self, f): """Get values from config file""" try: with open(f, 'r') as _fo: _seria_in = seria.load(_fo) _y = _seria_in.dump('yaml') except IOError: raise FiggypyError("could not open configuration file") self.values.up...
[ "def", "_load_file", "(", "self", ",", "f", ")", ":", "try", ":", "with", "open", "(", "f", ",", "'r'", ")", "as", "_fo", ":", "_seria_in", "=", "seria", ".", "load", "(", "_fo", ")", "_y", "=", "_seria_in", ".", "dump", "(", "'yaml'", ")", "ex...
Get values from config file
[ "Get", "values", "from", "config", "file" ]
324d1b281a8df20a26b92f42bf7fda0cca892116
https://github.com/theherk/figgypy/blob/324d1b281a8df20a26b92f42bf7fda0cca892116/figgypy/config.py#L96-L104
train
theherk/figgypy
figgypy/config.py
Config.setup
def setup(self, config_file=None, aws_config=None, gpg_config=None, decrypt_gpg=True, decrypt_kms=True): """Make setup easier by providing a constructor method. Move to config_file File can be located with a filename only, relative path, or absolute path. If only name or r...
python
def setup(self, config_file=None, aws_config=None, gpg_config=None, decrypt_gpg=True, decrypt_kms=True): """Make setup easier by providing a constructor method. Move to config_file File can be located with a filename only, relative path, or absolute path. If only name or r...
[ "def", "setup", "(", "self", ",", "config_file", "=", "None", ",", "aws_config", "=", "None", ",", "gpg_config", "=", "None", ",", "decrypt_gpg", "=", "True", ",", "decrypt_kms", "=", "True", ")", ":", "if", "aws_config", "is", "not", "None", ":", "sel...
Make setup easier by providing a constructor method. Move to config_file File can be located with a filename only, relative path, or absolute path. If only name or relative path is provided, look in this order: 1. current directory 2. `~/.config/<file_name>` 3. `/etc/<f...
[ "Make", "setup", "easier", "by", "providing", "a", "constructor", "method", "." ]
324d1b281a8df20a26b92f42bf7fda0cca892116
https://github.com/theherk/figgypy/blob/324d1b281a8df20a26b92f42bf7fda0cca892116/figgypy/config.py#L199-L227
train
kstaniek/condoor
condoor/protocols/console.py
Console.authenticate
def authenticate(self, driver): """Authenticate using the Console Server protocol specific FSM.""" # 0 1 2 3 events = [driver.username_re, driver.password_re, self.device.prompt_re, driver.rommon_re, ...
python
def authenticate(self, driver): """Authenticate using the Console Server protocol specific FSM.""" # 0 1 2 3 events = [driver.username_re, driver.password_re, self.device.prompt_re, driver.rommon_re, ...
[ "def", "authenticate", "(", "self", ",", "driver", ")", ":", "events", "=", "[", "driver", ".", "username_re", ",", "driver", ".", "password_re", ",", "self", ".", "device", ".", "prompt_re", ",", "driver", ".", "rommon_re", ",", "driver", ".", "unable_t...
Authenticate using the Console Server protocol specific FSM.
[ "Authenticate", "using", "the", "Console", "Server", "protocol", "specific", "FSM", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/protocols/console.py#L70-L95
train
kstaniek/condoor
condoor/utils.py
delegate
def delegate(attribute_name, method_names): """Pass the call to the attribute called attribute_name for every method listed in method_names.""" # hack for python 2.7 as nonlocal is not available info = { 'attribute': attribute_name, 'methods': method_names } def decorator(cls): ...
python
def delegate(attribute_name, method_names): """Pass the call to the attribute called attribute_name for every method listed in method_names.""" # hack for python 2.7 as nonlocal is not available info = { 'attribute': attribute_name, 'methods': method_names } def decorator(cls): ...
[ "def", "delegate", "(", "attribute_name", ",", "method_names", ")", ":", "info", "=", "{", "'attribute'", ":", "attribute_name", ",", "'methods'", ":", "method_names", "}", "def", "decorator", "(", "cls", ")", ":", "attribute", "=", "info", "[", "'attribute'...
Pass the call to the attribute called attribute_name for every method listed in method_names.
[ "Pass", "the", "call", "to", "the", "attribute", "called", "attribute_name", "for", "every", "method", "listed", "in", "method_names", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/utils.py#L12-L29
train
kstaniek/condoor
condoor/utils.py
pattern_to_str
def pattern_to_str(pattern): """Convert regex pattern to string. If pattern is string it returns itself, if pattern is SRE_Pattern then return pattern attribute :param pattern: pattern object or string :return: str: pattern sttring """ if isinstance(pattern, str): return repr(patter...
python
def pattern_to_str(pattern): """Convert regex pattern to string. If pattern is string it returns itself, if pattern is SRE_Pattern then return pattern attribute :param pattern: pattern object or string :return: str: pattern sttring """ if isinstance(pattern, str): return repr(patter...
[ "def", "pattern_to_str", "(", "pattern", ")", ":", "if", "isinstance", "(", "pattern", ",", "str", ")", ":", "return", "repr", "(", "pattern", ")", "else", ":", "return", "repr", "(", "pattern", ".", "pattern", ")", "if", "pattern", "else", "None" ]
Convert regex pattern to string. If pattern is string it returns itself, if pattern is SRE_Pattern then return pattern attribute :param pattern: pattern object or string :return: str: pattern sttring
[ "Convert", "regex", "pattern", "to", "string", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/utils.py#L85-L96
train
kstaniek/condoor
condoor/utils.py
levenshtein_distance
def levenshtein_distance(str_a, str_b): """Calculate the Levenshtein distance between string a and b. :param str_a: String - input string a :param str_b: String - input string b :return: Number - Levenshtein Distance between string a and b """ len_a, len_b = len(str_a), len(str_b) if len_a ...
python
def levenshtein_distance(str_a, str_b): """Calculate the Levenshtein distance between string a and b. :param str_a: String - input string a :param str_b: String - input string b :return: Number - Levenshtein Distance between string a and b """ len_a, len_b = len(str_a), len(str_b) if len_a ...
[ "def", "levenshtein_distance", "(", "str_a", ",", "str_b", ")", ":", "len_a", ",", "len_b", "=", "len", "(", "str_a", ")", ",", "len", "(", "str_b", ")", "if", "len_a", ">", "len_b", ":", "str_a", ",", "str_b", "=", "str_b", ",", "str_a", "len_a", ...
Calculate the Levenshtein distance between string a and b. :param str_a: String - input string a :param str_b: String - input string b :return: Number - Levenshtein Distance between string a and b
[ "Calculate", "the", "Levenshtein", "distance", "between", "string", "a", "and", "b", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/utils.py#L99-L119
train
kstaniek/condoor
condoor/utils.py
parse_inventory
def parse_inventory(inventory_output=None): """Parse the inventory text and return udi dict.""" udi = { "name": "", "description": "", "pid": "", "vid": "", "sn": "" } if inventory_output is None: return udi # find the record with chassis text in name...
python
def parse_inventory(inventory_output=None): """Parse the inventory text and return udi dict.""" udi = { "name": "", "description": "", "pid": "", "vid": "", "sn": "" } if inventory_output is None: return udi # find the record with chassis text in name...
[ "def", "parse_inventory", "(", "inventory_output", "=", "None", ")", ":", "udi", "=", "{", "\"name\"", ":", "\"\"", ",", "\"description\"", ":", "\"\"", ",", "\"pid\"", ":", "\"\"", ",", "\"vid\"", ":", "\"\"", ",", "\"sn\"", ":", "\"\"", "}", "if", "i...
Parse the inventory text and return udi dict.
[ "Parse", "the", "inventory", "text", "and", "return", "udi", "dict", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/utils.py#L122-L165
train
kstaniek/condoor
condoor/utils.py
normalize_urls
def normalize_urls(urls): """Overload urls and make list of lists of urls.""" _urls = [] if isinstance(urls, list): if urls: if isinstance(urls[0], list): # multiple connections (list of the lists) _urls = urls elif isinstance(urls[0], str): ...
python
def normalize_urls(urls): """Overload urls and make list of lists of urls.""" _urls = [] if isinstance(urls, list): if urls: if isinstance(urls[0], list): # multiple connections (list of the lists) _urls = urls elif isinstance(urls[0], str): ...
[ "def", "normalize_urls", "(", "urls", ")", ":", "_urls", "=", "[", "]", "if", "isinstance", "(", "urls", ",", "list", ")", ":", "if", "urls", ":", "if", "isinstance", "(", "urls", "[", "0", "]", ",", "list", ")", ":", "_urls", "=", "urls", "elif"...
Overload urls and make list of lists of urls.
[ "Overload", "urls", "and", "make", "list", "of", "lists", "of", "urls", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/utils.py#L233-L248
train
kstaniek/condoor
condoor/utils.py
yaml_file_to_dict
def yaml_file_to_dict(script_name, path=None): """Read yaml file and return the dict. It assumes the module file exists with the defaults. If the CONDOOR_{SCRIPT_NAME} env is set then the user file from the env is loaded and merged with the default There can be user file located in ~/.condoor director...
python
def yaml_file_to_dict(script_name, path=None): """Read yaml file and return the dict. It assumes the module file exists with the defaults. If the CONDOOR_{SCRIPT_NAME} env is set then the user file from the env is loaded and merged with the default There can be user file located in ~/.condoor director...
[ "def", "yaml_file_to_dict", "(", "script_name", ",", "path", "=", "None", ")", ":", "def", "load_yaml", "(", "file_path", ")", ":", "with", "open", "(", "file_path", ",", "'r'", ")", "as", "yamlfile", ":", "try", ":", "dictionary", "=", "yaml", ".", "l...
Read yaml file and return the dict. It assumes the module file exists with the defaults. If the CONDOOR_{SCRIPT_NAME} env is set then the user file from the env is loaded and merged with the default There can be user file located in ~/.condoor directory with the {script_name}.yaml filename. If exists ...
[ "Read", "yaml", "file", "and", "return", "the", "dict", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/utils.py#L280-L323
train
kstaniek/condoor
condoor/utils.py
FilteredFile.write
def write(self, text): """Override the standard write method to filter the content.""" index = text.find('\n') if index == -1: self._buffer = self._buffer + text else: self._buffer = self._buffer + text[:index + 1] if self._pattern: # p...
python
def write(self, text): """Override the standard write method to filter the content.""" index = text.find('\n') if index == -1: self._buffer = self._buffer + text else: self._buffer = self._buffer + text[:index + 1] if self._pattern: # p...
[ "def", "write", "(", "self", ",", "text", ")", ":", "index", "=", "text", ".", "find", "(", "'\\n'", ")", "if", "index", "==", "-", "1", ":", "self", ".", "_buffer", "=", "self", ".", "_buffer", "+", "text", "else", ":", "self", ".", "_buffer", ...
Override the standard write method to filter the content.
[ "Override", "the", "standard", "write", "method", "to", "filter", "the", "content", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/utils.py#L193-L209
train
ajdavis/GreenletProfiler
_vendorized_yappi/yappi.py
start
def start(builtins=False, profile_threads=True): """ Start profiler. """ if profile_threads: threading.setprofile(_callback) _yappi.start(builtins, profile_threads)
python
def start(builtins=False, profile_threads=True): """ Start profiler. """ if profile_threads: threading.setprofile(_callback) _yappi.start(builtins, profile_threads)
[ "def", "start", "(", "builtins", "=", "False", ",", "profile_threads", "=", "True", ")", ":", "if", "profile_threads", ":", "threading", ".", "setprofile", "(", "_callback", ")", "_yappi", ".", "start", "(", "builtins", ",", "profile_threads", ")" ]
Start profiler.
[ "Start", "profiler", "." ]
700349864a4f368a8a73a2a60f048c2e818d7cea
https://github.com/ajdavis/GreenletProfiler/blob/700349864a4f368a8a73a2a60f048c2e818d7cea/_vendorized_yappi/yappi.py#L700-L706
train
ajdavis/GreenletProfiler
_vendorized_yappi/yappi.py
set_clock_type
def set_clock_type(type): """ Sets the internal clock type for timing. Profiler shall not have any previous stats. Otherwise an exception is thrown. """ type = type.upper() if type not in CLOCK_TYPES: raise YappiError("Invalid clock type:%s" % (type)) _yappi.set_clock_type(C...
python
def set_clock_type(type): """ Sets the internal clock type for timing. Profiler shall not have any previous stats. Otherwise an exception is thrown. """ type = type.upper() if type not in CLOCK_TYPES: raise YappiError("Invalid clock type:%s" % (type)) _yappi.set_clock_type(C...
[ "def", "set_clock_type", "(", "type", ")", ":", "type", "=", "type", ".", "upper", "(", ")", "if", "type", "not", "in", "CLOCK_TYPES", ":", "raise", "YappiError", "(", "\"Invalid clock type:%s\"", "%", "(", "type", ")", ")", "_yappi", ".", "set_clock_type"...
Sets the internal clock type for timing. Profiler shall not have any previous stats. Otherwise an exception is thrown.
[ "Sets", "the", "internal", "clock", "type", "for", "timing", ".", "Profiler", "shall", "not", "have", "any", "previous", "stats", ".", "Otherwise", "an", "exception", "is", "thrown", "." ]
700349864a4f368a8a73a2a60f048c2e818d7cea
https://github.com/ajdavis/GreenletProfiler/blob/700349864a4f368a8a73a2a60f048c2e818d7cea/_vendorized_yappi/yappi.py#L755-L764
train
hwmrocker/smtplibaio
smtplibaio/streams.py
SMTPStreamReader.read_reply
async def read_reply(self): """ Reads a reply from the server. Raises: ConnectionResetError: If the connection with the server is lost (we can't read any response anymore). Or if the server replies without a proper return code. Returns: ...
python
async def read_reply(self): """ Reads a reply from the server. Raises: ConnectionResetError: If the connection with the server is lost (we can't read any response anymore). Or if the server replies without a proper return code. Returns: ...
[ "async", "def", "read_reply", "(", "self", ")", ":", "code", "=", "500", "messages", "=", "[", "]", "go_on", "=", "True", "while", "go_on", ":", "try", ":", "line", "=", "await", "self", ".", "readline", "(", ")", "except", "ValueError", "as", "e", ...
Reads a reply from the server. Raises: ConnectionResetError: If the connection with the server is lost (we can't read any response anymore). Or if the server replies without a proper return code. Returns: (int, str): A (code, full_message) 2-tupl...
[ "Reads", "a", "reply", "from", "the", "server", "." ]
84ce8e45b7e706476739d0efcb416c18ecabbbb6
https://github.com/hwmrocker/smtplibaio/blob/84ce8e45b7e706476739d0efcb416c18ecabbbb6/smtplibaio/streams.py#L31-L79
train
kstaniek/condoor
condoor/hopinfo.py
make_hop_info_from_url
def make_hop_info_from_url(url, verify_reachability=None): """Build HopInfo object from url. It allows only telnet and ssh as a valid protocols. Args: url (str): The url string describing the node. i.e. telnet://username@1.1.1.1. The protocol, username and address portion o...
python
def make_hop_info_from_url(url, verify_reachability=None): """Build HopInfo object from url. It allows only telnet and ssh as a valid protocols. Args: url (str): The url string describing the node. i.e. telnet://username@1.1.1.1. The protocol, username and address portion o...
[ "def", "make_hop_info_from_url", "(", "url", ",", "verify_reachability", "=", "None", ")", ":", "parsed", "=", "urlparse", "(", "url", ")", "username", "=", "None", "if", "parsed", ".", "username", "is", "None", "else", "unquote", "(", "parsed", ".", "user...
Build HopInfo object from url. It allows only telnet and ssh as a valid protocols. Args: url (str): The url string describing the node. i.e. telnet://username@1.1.1.1. The protocol, username and address portion of url is mandatory. Port and password is optional. If ...
[ "Build", "HopInfo", "object", "from", "url", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/hopinfo.py#L16-L63
train
kstaniek/condoor
condoor/hopinfo.py
HopInfo.is_reachable
def is_reachable(self): """Return if host is reachable.""" if self.verify_reachability and \ hasattr(self.verify_reachability, '__call__'): return self.verify_reachability(host=self.hostname, port=self.port) # assume is reachable if can't verify return True
python
def is_reachable(self): """Return if host is reachable.""" if self.verify_reachability and \ hasattr(self.verify_reachability, '__call__'): return self.verify_reachability(host=self.hostname, port=self.port) # assume is reachable if can't verify return True
[ "def", "is_reachable", "(", "self", ")", ":", "if", "self", ".", "verify_reachability", "and", "hasattr", "(", "self", ".", "verify_reachability", ",", "'__call__'", ")", ":", "return", "self", ".", "verify_reachability", "(", "host", "=", "self", ".", "host...
Return if host is reachable.
[ "Return", "if", "host", "is", "reachable", "." ]
77c054b29d4e286c1d7aca2c74dff86b805e1fae
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/hopinfo.py#L118-L124
train