repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI.add_language_to_project
def add_language_to_project(self, project_id, language_code): """ Adds a new language to project """ self._run( url_path="languages/add", id=project_id, language=language_code ) return True
python
def add_language_to_project(self, project_id, language_code): """ Adds a new language to project """ self._run( url_path="languages/add", id=project_id, language=language_code ) return True
[ "def", "add_language_to_project", "(", "self", ",", "project_id", ",", "language_code", ")", ":", "self", ".", "_run", "(", "url_path", "=", "\"languages/add\"", ",", "id", "=", "project_id", ",", "language", "=", "language_code", ")", "return", "True" ]
Adds a new language to project
[ "Adds", "a", "new", "language", "to", "project" ]
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L253-L262
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI.update_terms
def update_terms(self, project_id, data, fuzzy_trigger=None): """ Updates project terms. Lets you change the text, context, reference, plural and tags. >>> data = [ { "term": "Add new list", "context": "", "new_term": "...
python
def update_terms(self, project_id, data, fuzzy_trigger=None): """ Updates project terms. Lets you change the text, context, reference, plural and tags. >>> data = [ { "term": "Add new list", "context": "", "new_term": "...
[ "def", "update_terms", "(", "self", ",", "project_id", ",", "data", ",", "fuzzy_trigger", "=", "None", ")", ":", "kwargs", "=", "{", "}", "if", "fuzzy_trigger", "is", "not", "None", ":", "kwargs", "[", "'fuzzy_trigger'", "]", "=", "fuzzy_trigger", "data", ...
Updates project terms. Lets you change the text, context, reference, plural and tags. >>> data = [ { "term": "Add new list", "context": "", "new_term": "Save list", "new_context": "", "reference"...
[ "Updates", "project", "terms", ".", "Lets", "you", "change", "the", "text", "context", "reference", "plural", "and", "tags", "." ]
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L344-L380
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI.add_comment
def add_comment(self, project_id, data): """ Adds comments to existing terms. >>> data = [ { "term": "Add new list", "context": "", "comment": "This is a button" }, { "...
python
def add_comment(self, project_id, data): """ Adds comments to existing terms. >>> data = [ { "term": "Add new list", "context": "", "comment": "This is a button" }, { "...
[ "def", "add_comment", "(", "self", ",", "project_id", ",", "data", ")", ":", "data", "=", "self", ".", "_run", "(", "url_path", "=", "\"terms/add_comment\"", ",", "id", "=", "project_id", ",", "data", "=", "json", ".", "dumps", "(", "data", ")", ")", ...
Adds comments to existing terms. >>> data = [ { "term": "Add new list", "context": "", "comment": "This is a button" }, { "term": "one project found", "context": ""...
[ "Adds", "comments", "to", "existing", "terms", ".", ">>>", "data", "=", "[", "{", "term", ":", "Add", "new", "list", "context", ":", "comment", ":", "This", "is", "a", "button", "}", "{", "term", ":", "one", "project", "found", "context", ":", "comme...
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L403-L429
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI.update_project_language
def update_project_language(self, project_id, language_code, data, fuzzy_trigger=None): """ Inserts / overwrites translations. >>> data = [ { "term": "Projects", "context": "project list", "translation": { "content":...
python
def update_project_language(self, project_id, language_code, data, fuzzy_trigger=None): """ Inserts / overwrites translations. >>> data = [ { "term": "Projects", "context": "project list", "translation": { "content":...
[ "def", "update_project_language", "(", "self", ",", "project_id", ",", "language_code", ",", "data", ",", "fuzzy_trigger", "=", "None", ")", ":", "kwargs", "=", "{", "}", "if", "fuzzy_trigger", "is", "not", "None", ":", "kwargs", "[", "'fuzzy_trigger'", "]",...
Inserts / overwrites translations. >>> data = [ { "term": "Projects", "context": "project list", "translation": { "content": "Des projets", "fuzzy": 0 } } ]
[ "Inserts", "/", "overwrites", "translations", ".", ">>>", "data", "=", "[", "{", "term", ":", "Projects", "context", ":", "project", "list", "translation", ":", "{", "content", ":", "Des", "projets", "fuzzy", ":", "0", "}", "}", "]" ]
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L474-L499
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI.export
def export(self, project_id, language_code, file_type='po', filters=None, tags=None, local_file=None): """ Return terms / translations filters - filter by self._filter_by tags - filter results by tags; local_file - save content into it. If None, save content into ...
python
def export(self, project_id, language_code, file_type='po', filters=None, tags=None, local_file=None): """ Return terms / translations filters - filter by self._filter_by tags - filter results by tags; local_file - save content into it. If None, save content into ...
[ "def", "export", "(", "self", ",", "project_id", ",", "language_code", ",", "file_type", "=", "'po'", ",", "filters", "=", "None", ",", "tags", "=", "None", ",", "local_file", "=", "None", ")", ":", "if", "file_type", "not", "in", "self", ".", "FILE_TY...
Return terms / translations filters - filter by self._filter_by tags - filter results by tags; local_file - save content into it. If None, save content into random temp file. >>> tags = 'name-of-tag' >>> tags = ["name-of-tag"] >>> tags = ["name-of-tag", "nam...
[ "Return", "terms", "/", "translations" ]
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L501-L552
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI._upload
def _upload(self, project_id, updating, file_path, language_code=None, overwrite=False, sync_terms=False, tags=None, fuzzy_trigger=None): """ Internal: updates terms / translations File uploads are limited to one every 30 seconds """ options = [ self....
python
def _upload(self, project_id, updating, file_path, language_code=None, overwrite=False, sync_terms=False, tags=None, fuzzy_trigger=None): """ Internal: updates terms / translations File uploads are limited to one every 30 seconds """ options = [ self....
[ "def", "_upload", "(", "self", ",", "project_id", ",", "updating", ",", "file_path", ",", "language_code", "=", "None", ",", "overwrite", "=", "False", ",", "sync_terms", "=", "False", ",", "tags", "=", "None", ",", "fuzzy_trigger", "=", "None", ")", ":"...
Internal: updates terms / translations File uploads are limited to one every 30 seconds
[ "Internal", ":", "updates", "terms", "/", "translations" ]
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L554-L605
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI.update_terms
def update_terms(self, project_id, file_path=None, language_code=None, overwrite=False, sync_terms=False, tags=None, fuzzy_trigger=None): """ Updates terms overwrite: set it to True if you want to overwrite translations sync_terms: set it to True if you want to sync...
python
def update_terms(self, project_id, file_path=None, language_code=None, overwrite=False, sync_terms=False, tags=None, fuzzy_trigger=None): """ Updates terms overwrite: set it to True if you want to overwrite translations sync_terms: set it to True if you want to sync...
[ "def", "update_terms", "(", "self", ",", "project_id", ",", "file_path", "=", "None", ",", "language_code", "=", "None", ",", "overwrite", "=", "False", ",", "sync_terms", "=", "False", ",", "tags", "=", "None", ",", "fuzzy_trigger", "=", "None", ")", ":...
Updates terms overwrite: set it to True if you want to overwrite translations sync_terms: set it to True if you want to sync your terms (terms that are not found in the uploaded file will be deleted from project and the new ones added). Ignored if updating = translations ...
[ "Updates", "terms" ]
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L607-L633
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI.update_terms_translations
def update_terms_translations(self, project_id, file_path=None, language_code=None, overwrite=False, sync_terms=False, tags=None, fuzzy_trigger=None): """ Updates terms translations overwrite: set it to True if you want to overwr...
python
def update_terms_translations(self, project_id, file_path=None, language_code=None, overwrite=False, sync_terms=False, tags=None, fuzzy_trigger=None): """ Updates terms translations overwrite: set it to True if you want to overwr...
[ "def", "update_terms_translations", "(", "self", ",", "project_id", ",", "file_path", "=", "None", ",", "language_code", "=", "None", ",", "overwrite", "=", "False", ",", "sync_terms", "=", "False", ",", "tags", "=", "None", ",", "fuzzy_trigger", "=", "None"...
Updates terms translations overwrite: set it to True if you want to overwrite translations sync_terms: set it to True if you want to sync your terms (terms that are not found in the uploaded file will be deleted from project and the new ones added). Ignored if updating = transla...
[ "Updates", "terms", "translations" ]
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L652-L679
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI.update_translations
def update_translations(self, project_id, file_path=None, language_code=None, overwrite=False, fuzzy_trigger=None): """ Updates translations overwrite: set it to True if you want to overwrite definitions fuzzy_trigger: set it to True to mark corresponding tra...
python
def update_translations(self, project_id, file_path=None, language_code=None, overwrite=False, fuzzy_trigger=None): """ Updates translations overwrite: set it to True if you want to overwrite definitions fuzzy_trigger: set it to True to mark corresponding tra...
[ "def", "update_translations", "(", "self", ",", "project_id", ",", "file_path", "=", "None", ",", "language_code", "=", "None", ",", "overwrite", "=", "False", ",", "fuzzy_trigger", "=", "None", ")", ":", "return", "self", ".", "_upload", "(", "project_id", ...
Updates translations overwrite: set it to True if you want to overwrite definitions fuzzy_trigger: set it to True to mark corresponding translations from the other languages as fuzzy for the updated values
[ "Updates", "translations" ]
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L695-L711
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI.list_contributors
def list_contributors(self, project_id=None, language_code=None): """ Returns the list of contributors """ data = self._run( url_path="contributors/list", id=project_id, language=language_code ) return data['result'].get('contributors',...
python
def list_contributors(self, project_id=None, language_code=None): """ Returns the list of contributors """ data = self._run( url_path="contributors/list", id=project_id, language=language_code ) return data['result'].get('contributors',...
[ "def", "list_contributors", "(", "self", ",", "project_id", "=", "None", ",", "language_code", "=", "None", ")", ":", "data", "=", "self", ".", "_run", "(", "url_path", "=", "\"contributors/list\"", ",", "id", "=", "project_id", ",", "language", "=", "lang...
Returns the list of contributors
[ "Returns", "the", "list", "of", "contributors" ]
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L723-L732
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI.add_contributor
def add_contributor(self, project_id, name, email, language_code): """ Adds a contributor to a project language """ self._run( url_path="contributors/add", id=project_id, name=name, email=email, language=language_code ) ...
python
def add_contributor(self, project_id, name, email, language_code): """ Adds a contributor to a project language """ self._run( url_path="contributors/add", id=project_id, name=name, email=email, language=language_code ) ...
[ "def", "add_contributor", "(", "self", ",", "project_id", ",", "name", ",", "email", ",", "language_code", ")", ":", "self", ".", "_run", "(", "url_path", "=", "\"contributors/add\"", ",", "id", "=", "project_id", ",", "name", "=", "name", ",", "email", ...
Adds a contributor to a project language
[ "Adds", "a", "contributor", "to", "a", "project", "language" ]
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L734-L745
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI.add_administrator
def add_administrator(self, project_id, name, email): """ Adds a contributor to a project language """ self._run( url_path="contributors/add", id=project_id, name=name, email=email, admin=True ) return True
python
def add_administrator(self, project_id, name, email): """ Adds a contributor to a project language """ self._run( url_path="contributors/add", id=project_id, name=name, email=email, admin=True ) return True
[ "def", "add_administrator", "(", "self", ",", "project_id", ",", "name", ",", "email", ")", ":", "self", ".", "_run", "(", "url_path", "=", "\"contributors/add\"", ",", "id", "=", "project_id", ",", "name", "=", "name", ",", "email", "=", "email", ",", ...
Adds a contributor to a project language
[ "Adds", "a", "contributor", "to", "a", "project", "language" ]
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L747-L758
sporteasy/python-poeditor
poeditor/client.py
POEditorAPI.remove_contributor
def remove_contributor(self, project_id, email, language): """ Removes a contributor """ self._run( url_path="contributors/remove", id=project_id, email=email, language=language ) return True
python
def remove_contributor(self, project_id, email, language): """ Removes a contributor """ self._run( url_path="contributors/remove", id=project_id, email=email, language=language ) return True
[ "def", "remove_contributor", "(", "self", ",", "project_id", ",", "email", ",", "language", ")", ":", "self", ".", "_run", "(", "url_path", "=", "\"contributors/remove\"", ",", "id", "=", "project_id", ",", "email", "=", "email", ",", "language", "=", "lan...
Removes a contributor
[ "Removes", "a", "contributor" ]
train
https://github.com/sporteasy/python-poeditor/blob/e9c0a8ab08816903122f730b73ffaab46601076c/poeditor/client.py#L760-L770
kennell/schiene
schiene/schiene.py
parse_stations
def parse_stations(html): """ Strips JS code, loads JSON """ html = html.replace('SLs.sls=', '').replace(';SLs.showSuggestion();', '') html = json.loads(html) return html['suggestions']
python
def parse_stations(html): """ Strips JS code, loads JSON """ html = html.replace('SLs.sls=', '').replace(';SLs.showSuggestion();', '') html = json.loads(html) return html['suggestions']
[ "def", "parse_stations", "(", "html", ")", ":", "html", "=", "html", ".", "replace", "(", "'SLs.sls='", ",", "''", ")", ".", "replace", "(", "';SLs.showSuggestion();'", ",", "''", ")", "html", "=", "json", ".", "loads", "(", "html", ")", "return", "htm...
Strips JS code, loads JSON
[ "Strips", "JS", "code", "loads", "JSON" ]
train
https://github.com/kennell/schiene/blob/a8f1ba2bd30f9f4a373c7b0ced589bd60121aa1f/schiene/schiene.py#L40-L46
kennell/schiene
schiene/schiene.py
parse_delay
def parse_delay(data): """ Prase the delay """ # parse data from the details view rsp = requests.get(data['details']) soup = BeautifulSoup(rsp.text, "html.parser") # get departure delay delay_departure_raw = soup.find('div', class_="routeStart").find('span', class_=["delay", "delayO...
python
def parse_delay(data): """ Prase the delay """ # parse data from the details view rsp = requests.get(data['details']) soup = BeautifulSoup(rsp.text, "html.parser") # get departure delay delay_departure_raw = soup.find('div', class_="routeStart").find('span', class_=["delay", "delayO...
[ "def", "parse_delay", "(", "data", ")", ":", "# parse data from the details view", "rsp", "=", "requests", ".", "get", "(", "data", "[", "'details'", "]", ")", "soup", "=", "BeautifulSoup", "(", "rsp", ".", "text", ",", "\"html.parser\"", ")", "# get departure...
Prase the delay
[ "Prase", "the", "delay" ]
train
https://github.com/kennell/schiene/blob/a8f1ba2bd30f9f4a373c7b0ced589bd60121aa1f/schiene/schiene.py#L48-L85
kennell/schiene
schiene/schiene.py
calculate_delay
def calculate_delay(original, delay): """ Calculate the delay """ original = datetime.strptime(original, '%H:%M') delayed = datetime.strptime(delay, '%H:%M') diff = delayed - original return diff.total_seconds() // 60
python
def calculate_delay(original, delay): """ Calculate the delay """ original = datetime.strptime(original, '%H:%M') delayed = datetime.strptime(delay, '%H:%M') diff = delayed - original return diff.total_seconds() // 60
[ "def", "calculate_delay", "(", "original", ",", "delay", ")", ":", "original", "=", "datetime", ".", "strptime", "(", "original", ",", "'%H:%M'", ")", "delayed", "=", "datetime", ".", "strptime", "(", "delay", ",", "'%H:%M'", ")", "diff", "=", "delayed", ...
Calculate the delay
[ "Calculate", "the", "delay" ]
train
https://github.com/kennell/schiene/blob/a8f1ba2bd30f9f4a373c7b0ced589bd60121aa1f/schiene/schiene.py#L87-L94
kennell/schiene
schiene/schiene.py
Schiene.stations
def stations(self, station, limit=10): """ Find stations for given queries Args: station (str): search query limit (int): limit number of results """ query = { 'start': 1, 'S': station + '?', 'REQ0JourneyStopsB': limit ...
python
def stations(self, station, limit=10): """ Find stations for given queries Args: station (str): search query limit (int): limit number of results """ query = { 'start': 1, 'S': station + '?', 'REQ0JourneyStopsB': limit ...
[ "def", "stations", "(", "self", ",", "station", ",", "limit", "=", "10", ")", ":", "query", "=", "{", "'start'", ":", "1", ",", "'S'", ":", "station", "+", "'?'", ",", "'REQ0JourneyStopsB'", ":", "limit", "}", "rsp", "=", "requests", ".", "get", "(...
Find stations for given queries Args: station (str): search query limit (int): limit number of results
[ "Find", "stations", "for", "given", "queries" ]
train
https://github.com/kennell/schiene/blob/a8f1ba2bd30f9f4a373c7b0ced589bd60121aa1f/schiene/schiene.py#L99-L113
kennell/schiene
schiene/schiene.py
Schiene.connections
def connections(self, origin, destination, dt=datetime.now(), only_direct=False): """ Find connections between two stations Args: origin (str): origin station destination (str): destination station dt (datetime): date and time for query only_direc...
python
def connections(self, origin, destination, dt=datetime.now(), only_direct=False): """ Find connections between two stations Args: origin (str): origin station destination (str): destination station dt (datetime): date and time for query only_direc...
[ "def", "connections", "(", "self", ",", "origin", ",", "destination", ",", "dt", "=", "datetime", ".", "now", "(", ")", ",", "only_direct", "=", "False", ")", ":", "query", "=", "{", "'S'", ":", "origin", ",", "'Z'", ":", "destination", ",", "'date'"...
Find connections between two stations Args: origin (str): origin station destination (str): destination station dt (datetime): date and time for query only_direct (bool): only direct connections
[ "Find", "connections", "between", "two", "stations" ]
train
https://github.com/kennell/schiene/blob/a8f1ba2bd30f9f4a373c7b0ced589bd60121aa1f/schiene/schiene.py#L116-L135
seung-lab/python-task-queue
taskqueue/taskqueue.py
_scatter
def _scatter(sequence, n): """Scatters elements of ``sequence`` into ``n`` blocks.""" chunklen = int(math.ceil(float(len(sequence)) / float(n))) return [ sequence[ i*chunklen : (i+1)*chunklen ] for i in range(n) ]
python
def _scatter(sequence, n): """Scatters elements of ``sequence`` into ``n`` blocks.""" chunklen = int(math.ceil(float(len(sequence)) / float(n))) return [ sequence[ i*chunklen : (i+1)*chunklen ] for i in range(n) ]
[ "def", "_scatter", "(", "sequence", ",", "n", ")", ":", "chunklen", "=", "int", "(", "math", ".", "ceil", "(", "float", "(", "len", "(", "sequence", ")", ")", "/", "float", "(", "n", ")", ")", ")", "return", "[", "sequence", "[", "i", "*", "chu...
Scatters elements of ``sequence`` into ``n`` blocks.
[ "Scatters", "elements", "of", "sequence", "into", "n", "blocks", "." ]
train
https://github.com/seung-lab/python-task-queue/blob/e2742d0373e49c2a19badce102a355894924b4fb/taskqueue/taskqueue.py#L634-L640
seung-lab/python-task-queue
taskqueue/taskqueue.py
SuperTaskQueue.lease
def lease(self, seconds=600, num_tasks=1, tag=None): """ Acquires a lease on the topmost N unowned tasks in the specified queue. Required query parameters: leaseSecs, numTasks """ tag = tag if tag else None tasks = self._api.lease( numTasks=num_tasks, seconds=seconds, groupByT...
python
def lease(self, seconds=600, num_tasks=1, tag=None): """ Acquires a lease on the topmost N unowned tasks in the specified queue. Required query parameters: leaseSecs, numTasks """ tag = tag if tag else None tasks = self._api.lease( numTasks=num_tasks, seconds=seconds, groupByT...
[ "def", "lease", "(", "self", ",", "seconds", "=", "600", ",", "num_tasks", "=", "1", ",", "tag", "=", "None", ")", ":", "tag", "=", "tag", "if", "tag", "else", "None", "tasks", "=", "self", ".", "_api", ".", "lease", "(", "numTasks", "=", "num_ta...
Acquires a lease on the topmost N unowned tasks in the specified queue. Required query parameters: leaseSecs, numTasks
[ "Acquires", "a", "lease", "on", "the", "topmost", "N", "unowned", "tasks", "in", "the", "specified", "queue", ".", "Required", "query", "parameters", ":", "leaseSecs", "numTasks" ]
train
https://github.com/seung-lab/python-task-queue/blob/e2742d0373e49c2a19badce102a355894924b4fb/taskqueue/taskqueue.py#L168-L185
seung-lab/python-task-queue
taskqueue/taskqueue.py
SuperTaskQueue.purge
def purge(self): """Deletes all tasks in the queue.""" try: return self._api.purge() except AttributeError: while True: lst = self.list() if len(lst) == 0: break for task in lst: self.delete(task) self.wait() return self
python
def purge(self): """Deletes all tasks in the queue.""" try: return self._api.purge() except AttributeError: while True: lst = self.list() if len(lst) == 0: break for task in lst: self.delete(task) self.wait() return self
[ "def", "purge", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_api", ".", "purge", "(", ")", "except", "AttributeError", ":", "while", "True", ":", "lst", "=", "self", ".", "list", "(", ")", "if", "len", "(", "lst", ")", "==", "0", ...
Deletes all tasks in the queue.
[ "Deletes", "all", "tasks", "in", "the", "queue", "." ]
train
https://github.com/seung-lab/python-task-queue/blob/e2742d0373e49c2a19badce102a355894924b4fb/taskqueue/taskqueue.py#L194-L207
seung-lab/python-task-queue
taskqueue/taskqueue.py
SuperTaskQueue.poll
def poll( self, lease_seconds=LEASE_SECONDS, tag=None, verbose=False, execute_args=[], execute_kwargs={}, stop_fn=None, backoff_exceptions=[], min_backoff_window=30, max_backoff_window=120, log_fn=None ): """ Poll a queue until a stop condition is reached (default forever). Note that th...
python
def poll( self, lease_seconds=LEASE_SECONDS, tag=None, verbose=False, execute_args=[], execute_kwargs={}, stop_fn=None, backoff_exceptions=[], min_backoff_window=30, max_backoff_window=120, log_fn=None ): """ Poll a queue until a stop condition is reached (default forever). Note that th...
[ "def", "poll", "(", "self", ",", "lease_seconds", "=", "LEASE_SECONDS", ",", "tag", "=", "None", ",", "verbose", "=", "False", ",", "execute_args", "=", "[", "]", ",", "execute_kwargs", "=", "{", "}", ",", "stop_fn", "=", "None", ",", "backoff_exceptions...
Poll a queue until a stop condition is reached (default forever). Note that this function is not thread safe as it requires a global variable to intercept SIGINT. lease_seconds: each task should be leased for this many seconds tag: if specified, query for only tasks that match this tag execute_args ...
[ "Poll", "a", "queue", "until", "a", "stop", "condition", "is", "reached", "(", "default", "forever", ")", ".", "Note", "that", "this", "function", "is", "not", "thread", "safe", "as", "it", "requires", "a", "global", "variable", "to", "intercept", "SIGINT"...
train
https://github.com/seung-lab/python-task-queue/blob/e2742d0373e49c2a19badce102a355894924b4fb/taskqueue/taskqueue.py#L209-L303
seung-lab/python-task-queue
taskqueue/taskqueue.py
TaskQueue.insert
def insert(self, task, args=[], kwargs={}, delay_seconds=0): """ Insert a task into an existing queue. """ body = { "payload": task.payload(), "queueName": self._queue_name, "groupByTag": True, "tag": task.__class__.__name__ } def cloud_insertion(api): api.insert(b...
python
def insert(self, task, args=[], kwargs={}, delay_seconds=0): """ Insert a task into an existing queue. """ body = { "payload": task.payload(), "queueName": self._queue_name, "groupByTag": True, "tag": task.__class__.__name__ } def cloud_insertion(api): api.insert(b...
[ "def", "insert", "(", "self", ",", "task", ",", "args", "=", "[", "]", ",", "kwargs", "=", "{", "}", ",", "delay_seconds", "=", "0", ")", ":", "body", "=", "{", "\"payload\"", ":", "task", ".", "payload", "(", ")", ",", "\"queueName\"", ":", "sel...
Insert a task into an existing queue.
[ "Insert", "a", "task", "into", "an", "existing", "queue", "." ]
train
https://github.com/seung-lab/python-task-queue/blob/e2742d0373e49c2a19badce102a355894924b4fb/taskqueue/taskqueue.py#L332-L351
seung-lab/python-task-queue
taskqueue/taskqueue.py
TaskQueue.delete
def delete(self, task_id): """Deletes a task from a TaskQueue.""" if isinstance(task_id, RegisteredTask): task_id = task_id.id def cloud_delete(api): api.delete(task_id) if len(self._threads): self.put(cloud_delete) else: cloud_delete(self._api) return self
python
def delete(self, task_id): """Deletes a task from a TaskQueue.""" if isinstance(task_id, RegisteredTask): task_id = task_id.id def cloud_delete(api): api.delete(task_id) if len(self._threads): self.put(cloud_delete) else: cloud_delete(self._api) return self
[ "def", "delete", "(", "self", ",", "task_id", ")", ":", "if", "isinstance", "(", "task_id", ",", "RegisteredTask", ")", ":", "task_id", "=", "task_id", ".", "id", "def", "cloud_delete", "(", "api", ")", ":", "api", ".", "delete", "(", "task_id", ")", ...
Deletes a task from a TaskQueue.
[ "Deletes", "a", "task", "from", "a", "TaskQueue", "." ]
train
https://github.com/seung-lab/python-task-queue/blob/e2742d0373e49c2a19badce102a355894924b4fb/taskqueue/taskqueue.py#L381-L394
seung-lab/python-task-queue
taskqueue/taskqueue.py
GreenTaskQueue.insert
def insert(self, task, args=[], kwargs={}, delay_seconds=0): """ Insert a task into an existing queue. """ body = { "payload": task.payload(), "queueName": self._queue_name, "groupByTag": True, "tag": task.__class__.__name__ } def cloud_insertion(): self._api.inser...
python
def insert(self, task, args=[], kwargs={}, delay_seconds=0): """ Insert a task into an existing queue. """ body = { "payload": task.payload(), "queueName": self._queue_name, "groupByTag": True, "tag": task.__class__.__name__ } def cloud_insertion(): self._api.inser...
[ "def", "insert", "(", "self", ",", "task", ",", "args", "=", "[", "]", ",", "kwargs", "=", "{", "}", ",", "delay_seconds", "=", "0", ")", ":", "body", "=", "{", "\"payload\"", ":", "task", ".", "payload", "(", ")", ",", "\"queueName\"", ":", "sel...
Insert a task into an existing queue.
[ "Insert", "a", "task", "into", "an", "existing", "queue", "." ]
train
https://github.com/seung-lab/python-task-queue/blob/e2742d0373e49c2a19badce102a355894924b4fb/taskqueue/taskqueue.py#L439-L455
Chris7/django-djangui
djangui/backend/argparse_specs.py
is_upload
def is_upload(action): """Checks if this should be a user upload :param action: :return: True if this is a file we intend to upload from the user """ return 'r' in action.type._mode and (action.default is None or getattr(action.default, 'name') not in (sys.s...
python
def is_upload(action): """Checks if this should be a user upload :param action: :return: True if this is a file we intend to upload from the user """ return 'r' in action.type._mode and (action.default is None or getattr(action.default, 'name') not in (sys.s...
[ "def", "is_upload", "(", "action", ")", ":", "return", "'r'", "in", "action", ".", "type", ".", "_mode", "and", "(", "action", ".", "default", "is", "None", "or", "getattr", "(", "action", ".", "default", ",", "'name'", ")", "not", "in", "(", "sys", ...
Checks if this should be a user upload :param action: :return: True if this is a file we intend to upload from the user
[ "Checks", "if", "this", "should", "be", "a", "user", "upload" ]
train
https://github.com/Chris7/django-djangui/blob/4e9e37ac92e128dbaa0c809e5e33618d2c96808f/djangui/backend/argparse_specs.py#L14-L21
Chris7/django-djangui
djangui/backend/argparse_specs.py
ArgParseNode.to_django
def to_django(self): """ This is a debug function to see what equivalent django models are being generated """ exclude = {'name', 'model'} field_module = 'models' django_kwargs = {} if self.node_attrs['model'] == 'CharField': django_kwargs['max_length...
python
def to_django(self): """ This is a debug function to see what equivalent django models are being generated """ exclude = {'name', 'model'} field_module = 'models' django_kwargs = {} if self.node_attrs['model'] == 'CharField': django_kwargs['max_length...
[ "def", "to_django", "(", "self", ")", ":", "exclude", "=", "{", "'name'", ",", "'model'", "}", "field_module", "=", "'models'", "django_kwargs", "=", "{", "}", "if", "self", ".", "node_attrs", "[", "'model'", "]", "==", "'CharField'", ":", "django_kwargs",...
This is a debug function to see what equivalent django models are being generated
[ "This", "is", "a", "debug", "function", "to", "see", "what", "equivalent", "django", "models", "are", "being", "generated" ]
train
https://github.com/Chris7/django-djangui/blob/4e9e37ac92e128dbaa0c809e5e33618d2c96808f/djangui/backend/argparse_specs.py#L152-L167
mozilla/configman
configman/converters.py
str_dict_keys
def str_dict_keys(a_dict): """return a modified dict where all the keys that are anything but str get converted to str. E.g. >>> result = str_dict_keys({u'name': u'Peter', u'age': 99, 1: 2}) >>> # can't compare whole dicts in doctests >>> result['name'] u'Peter' >>> result['ag...
python
def str_dict_keys(a_dict): """return a modified dict where all the keys that are anything but str get converted to str. E.g. >>> result = str_dict_keys({u'name': u'Peter', u'age': 99, 1: 2}) >>> # can't compare whole dicts in doctests >>> result['name'] u'Peter' >>> result['ag...
[ "def", "str_dict_keys", "(", "a_dict", ")", ":", "new_dict", "=", "{", "}", "for", "key", "in", "a_dict", ":", "if", "six", ".", "PY2", "and", "isinstance", "(", "key", ",", "six", ".", "text_type", ")", ":", "new_dict", "[", "str", "(", "key", ")"...
return a modified dict where all the keys that are anything but str get converted to str. E.g. >>> result = str_dict_keys({u'name': u'Peter', u'age': 99, 1: 2}) >>> # can't compare whole dicts in doctests >>> result['name'] u'Peter' >>> result['age'] 99 >>> result[1] ...
[ "return", "a", "modified", "dict", "where", "all", "the", "keys", "that", "are", "anything", "but", "str", "get", "converted", "to", "str", ".", "E", ".", "g", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/converters.py#L34-L73
mozilla/configman
configman/converters.py
str_to_boolean
def str_to_boolean(input_str): """ a conversion function for boolean """ if not isinstance(input_str, six.string_types): raise ValueError(input_str) input_str = str_quote_stripper(input_str) return input_str.lower() in ("true", "t", "1", "y", "yes")
python
def str_to_boolean(input_str): """ a conversion function for boolean """ if not isinstance(input_str, six.string_types): raise ValueError(input_str) input_str = str_quote_stripper(input_str) return input_str.lower() in ("true", "t", "1", "y", "yes")
[ "def", "str_to_boolean", "(", "input_str", ")", ":", "if", "not", "isinstance", "(", "input_str", ",", "six", ".", "string_types", ")", ":", "raise", "ValueError", "(", "input_str", ")", "input_str", "=", "str_quote_stripper", "(", "input_str", ")", "return", ...
a conversion function for boolean
[ "a", "conversion", "function", "for", "boolean" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/converters.py#L127-L133
mozilla/configman
configman/converters.py
str_to_python_object
def str_to_python_object(input_str): """ a conversion that will import a module and class name """ if not input_str: return None if six.PY3 and isinstance(input_str, six.binary_type): input_str = to_str(input_str) if not isinstance(input_str, six.string_types): # gosh, we did...
python
def str_to_python_object(input_str): """ a conversion that will import a module and class name """ if not input_str: return None if six.PY3 and isinstance(input_str, six.binary_type): input_str = to_str(input_str) if not isinstance(input_str, six.string_types): # gosh, we did...
[ "def", "str_to_python_object", "(", "input_str", ")", ":", "if", "not", "input_str", ":", "return", "None", "if", "six", ".", "PY3", "and", "isinstance", "(", "input_str", ",", "six", ".", "binary_type", ")", ":", "input_str", "=", "to_str", "(", "input_st...
a conversion that will import a module and class name
[ "a", "conversion", "that", "will", "import", "a", "module", "and", "class", "name" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/converters.py#L139-L172
mozilla/configman
configman/converters.py
str_to_classes_in_namespaces
def str_to_classes_in_namespaces( template_for_namespace="cls%d", name_of_class_option='cls', instantiate_classes=False ): """take a comma delimited list of class names, convert each class name into an actual class as an option within a numbered namespace. This function creates a closure over ...
python
def str_to_classes_in_namespaces( template_for_namespace="cls%d", name_of_class_option='cls', instantiate_classes=False ): """take a comma delimited list of class names, convert each class name into an actual class as an option within a numbered namespace. This function creates a closure over ...
[ "def", "str_to_classes_in_namespaces", "(", "template_for_namespace", "=", "\"cls%d\"", ",", "name_of_class_option", "=", "'cls'", ",", "instantiate_classes", "=", "False", ")", ":", "# these are only used within this method. No need to pollute the module", "# scope with them and ...
take a comma delimited list of class names, convert each class name into an actual class as an option within a numbered namespace. This function creates a closure over a new function. That new function, in turn creates a class derived from RequiredConfig. The inner function, 'class_list_converter', ...
[ "take", "a", "comma", "delimited", "list", "of", "class", "names", "convert", "each", "class", "name", "into", "an", "actual", "class", "as", "an", "option", "within", "a", "numbered", "namespace", ".", "This", "function", "creates", "a", "closure", "over", ...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/converters.py#L178-L301
mozilla/configman
configman/converters.py
str_to_list
def str_to_list( input_str, item_converter=lambda x: x, item_separator=',', list_to_collection_converter=None, ): """ a conversion function for list """ if not isinstance(input_str, six.string_types): raise ValueError(input_str) input_str = str_quote_stripper(input_str) resul...
python
def str_to_list( input_str, item_converter=lambda x: x, item_separator=',', list_to_collection_converter=None, ): """ a conversion function for list """ if not isinstance(input_str, six.string_types): raise ValueError(input_str) input_str = str_quote_stripper(input_str) resul...
[ "def", "str_to_list", "(", "input_str", ",", "item_converter", "=", "lambda", "x", ":", "x", ",", "item_separator", "=", "','", ",", "list_to_collection_converter", "=", "None", ",", ")", ":", "if", "not", "isinstance", "(", "input_str", ",", "six", ".", "...
a conversion function for list
[ "a", "conversion", "function", "for", "list" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/converters.py#L317-L334
mozilla/configman
configman/converters.py
arbitrary_object_to_string
def arbitrary_object_to_string(a_thing): """take a python object of some sort, and convert it into a human readable string. this function is used extensively to convert things like "subject" into "subject_key, function -> function_key, etc.""" # is it None? if a_thing is None: return '' ...
python
def arbitrary_object_to_string(a_thing): """take a python object of some sort, and convert it into a human readable string. this function is used extensively to convert things like "subject" into "subject_key, function -> function_key, etc.""" # is it None? if a_thing is None: return '' ...
[ "def", "arbitrary_object_to_string", "(", "a_thing", ")", ":", "# is it None?", "if", "a_thing", "is", "None", ":", "return", "''", "# is it already a string?", "if", "isinstance", "(", "a_thing", ",", "six", ".", "string_types", ")", ":", "return", "a_thing", "...
take a python object of some sort, and convert it into a human readable string. this function is used extensively to convert things like "subject" into "subject_key, function -> function_key, etc.
[ "take", "a", "python", "object", "of", "some", "sort", "and", "convert", "it", "into", "a", "human", "readable", "string", ".", "this", "function", "is", "used", "extensively", "to", "convert", "things", "like", "subject", "into", "subject_key", "function", ...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/converters.py#L370-L430
Chris7/django-djangui
djangui/backend/ast/codegen.py
to_source
def to_source(node, indent_with=' ' * 4, add_line_information=False): """This function can convert a node tree back into python sourcecode. This is useful for debugging purposes, especially if you're dealing with custom asts not generated by python itself. It could be that the sourcecode is evaluable w...
python
def to_source(node, indent_with=' ' * 4, add_line_information=False): """This function can convert a node tree back into python sourcecode. This is useful for debugging purposes, especially if you're dealing with custom asts not generated by python itself. It could be that the sourcecode is evaluable w...
[ "def", "to_source", "(", "node", ",", "indent_with", "=", "' '", "*", "4", ",", "add_line_information", "=", "False", ")", ":", "generator", "=", "SourceGenerator", "(", "indent_with", ",", "add_line_information", ")", "generator", ".", "visit", "(", "node", ...
This function can convert a node tree back into python sourcecode. This is useful for debugging purposes, especially if you're dealing with custom asts not generated by python itself. It could be that the sourcecode is evaluable when the AST itself is not compilable / evaluable. The reason for this is...
[ "This", "function", "can", "convert", "a", "node", "tree", "back", "into", "python", "sourcecode", ".", "This", "is", "useful", "for", "debugging", "purposes", "especially", "if", "you", "re", "dealing", "with", "custom", "asts", "not", "generated", "by", "p...
train
https://github.com/Chris7/django-djangui/blob/4e9e37ac92e128dbaa0c809e5e33618d2c96808f/djangui/backend/ast/codegen.py#L59-L79
mozilla/configman
demo/advanced_demo3.py
PostgresPooled.connection
def connection(self, name=None): """return a named connection. This function will return a named connection by either finding one in its pool by the name or creating a new one. If no name is given, it will use the name of the current executing thread as the name of the connecti...
python
def connection(self, name=None): """return a named connection. This function will return a named connection by either finding one in its pool by the name or creating a new one. If no name is given, it will use the name of the current executing thread as the name of the connecti...
[ "def", "connection", "(", "self", ",", "name", "=", "None", ")", ":", "if", "not", "name", ":", "name", "=", "threading", ".", "currentThread", "(", ")", ".", "getName", "(", ")", "if", "name", "in", "self", ".", "pool", ":", "return", "self", ".",...
return a named connection. This function will return a named connection by either finding one in its pool by the name or creating a new one. If no name is given, it will use the name of the current executing thread as the name of the connection. parameters: name - ...
[ "return", "a", "named", "connection", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/demo/advanced_demo3.py#L242-L258
mozilla/configman
demo/advanced_demo3.py
PostgresPooled.close_connection
def close_connection(self, connection, force=False): """overriding the baseclass function, this routine will decline to close a connection at the end of a transaction context. This allows for reuse of connections.""" if force: print('PostgresPooled - delegating connection cl...
python
def close_connection(self, connection, force=False): """overriding the baseclass function, this routine will decline to close a connection at the end of a transaction context. This allows for reuse of connections.""" if force: print('PostgresPooled - delegating connection cl...
[ "def", "close_connection", "(", "self", ",", "connection", ",", "force", "=", "False", ")", ":", "if", "force", ":", "print", "(", "'PostgresPooled - delegating connection closure'", ")", "try", ":", "super", "(", "PostgresPooled", ",", "self", ")", ".", "clos...
overriding the baseclass function, this routine will decline to close a connection at the end of a transaction context. This allows for reuse of connections.
[ "overriding", "the", "baseclass", "function", "this", "routine", "will", "decline", "to", "close", "a", "connection", "at", "the", "end", "of", "a", "transaction", "context", ".", "This", "allows", "for", "reuse", "of", "connections", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/demo/advanced_demo3.py#L261-L277
mozilla/configman
demo/advanced_demo3.py
TransactionExecutor.do_transaction
def do_transaction(self, function, *args, **kwargs): """execute a function within the context of a transaction""" with self.config.db_transaction() as trans: function(trans, *args, **kwargs)
python
def do_transaction(self, function, *args, **kwargs): """execute a function within the context of a transaction""" with self.config.db_transaction() as trans: function(trans, *args, **kwargs)
[ "def", "do_transaction", "(", "self", ",", "function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "self", ".", "config", ".", "db_transaction", "(", ")", "as", "trans", ":", "function", "(", "trans", ",", "*", "args", ",", "*", "*...
execute a function within the context of a transaction
[ "execute", "a", "function", "within", "the", "context", "of", "a", "transaction" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/demo/advanced_demo3.py#L323-L326
mozilla/configman
demo/advanced_demo3.py
TransactionExecutorWithBackoff.responsive_sleep
def responsive_sleep(self, seconds, wait_reason=''): """Sleep for the specified number of seconds, logging every 'wait_log_interval' seconds with progress info.""" for x in range(int(seconds)): if (self.config.wait_log_interval and not x % self.config.wait_log_interva...
python
def responsive_sleep(self, seconds, wait_reason=''): """Sleep for the specified number of seconds, logging every 'wait_log_interval' seconds with progress info.""" for x in range(int(seconds)): if (self.config.wait_log_interval and not x % self.config.wait_log_interva...
[ "def", "responsive_sleep", "(", "self", ",", "seconds", ",", "wait_reason", "=", "''", ")", ":", "for", "x", "in", "range", "(", "int", "(", "seconds", ")", ")", ":", "if", "(", "self", ".", "config", ".", "wait_log_interval", "and", "not", "x", "%",...
Sleep for the specified number of seconds, logging every 'wait_log_interval' seconds with progress info.
[ "Sleep", "for", "the", "specified", "number", "of", "seconds", "logging", "every", "wait_log_interval", "seconds", "with", "progress", "info", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/demo/advanced_demo3.py#L354-L363
mozilla/configman
demo/advanced_demo3.py
TransactionExecutorWithBackoff.do_transaction
def do_transaction(self, function, *args, **kwargs): """execute a function within the context of a transaction""" for wait_in_seconds in self.backoff_generator(): try: with self.config.db_transaction() as trans: function(trans, *args, **kwargs) ...
python
def do_transaction(self, function, *args, **kwargs): """execute a function within the context of a transaction""" for wait_in_seconds in self.backoff_generator(): try: with self.config.db_transaction() as trans: function(trans, *args, **kwargs) ...
[ "def", "do_transaction", "(", "self", ",", "function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "wait_in_seconds", "in", "self", ".", "backoff_generator", "(", ")", ":", "try", ":", "with", "self", ".", "config", ".", "db_transaction",...
execute a function within the context of a transaction
[ "execute", "a", "function", "within", "the", "context", "of", "a", "transaction" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/demo/advanced_demo3.py#L366-L380
mozilla/configman
configman/value_sources/for_configobj.py
ConfigObjWithIncludes._expand_files
def _expand_files(self, file_name, original_path, indent=""): """This recursive function accepts a file name, opens the file and then spools the contents of the file into a list, examining each line as it does so. If it detects a line beginning with "+include", it assumes the string imm...
python
def _expand_files(self, file_name, original_path, indent=""): """This recursive function accepts a file name, opens the file and then spools the contents of the file into a list, examining each line as it does so. If it detects a line beginning with "+include", it assumes the string imm...
[ "def", "_expand_files", "(", "self", ",", "file_name", ",", "original_path", ",", "indent", "=", "\"\"", ")", ":", "expanded_file_contents", "=", "[", "]", "with", "open", "(", "file_name", ")", "as", "f", ":", "for", "a_line", "in", "f", ":", "match", ...
This recursive function accepts a file name, opens the file and then spools the contents of the file into a list, examining each line as it does so. If it detects a line beginning with "+include", it assumes the string immediately following is a file name. Recursing, the file new file ...
[ "This", "recursive", "function", "accepts", "a", "file", "name", "opens", "the", "file", "and", "then", "spools", "the", "contents", "of", "the", "file", "into", "a", "list", "examining", "each", "line", "as", "it", "does", "so", ".", "If", "it", "detect...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/value_sources/for_configobj.py#L73-L98
mozilla/configman
configman/value_sources/for_configobj.py
ConfigObjWithIncludes._load
def _load(self, infile, configspec): """this overrides the original ConfigObj method of the same name. It runs through the input file collecting lines into a list. When completed, this method submits the list of lines to the super class' function of the same name. ConfigObj proceeds, ...
python
def _load(self, infile, configspec): """this overrides the original ConfigObj method of the same name. It runs through the input file collecting lines into a list. When completed, this method submits the list of lines to the super class' function of the same name. ConfigObj proceeds, ...
[ "def", "_load", "(", "self", ",", "infile", ",", "configspec", ")", ":", "if", "isinstance", "(", "infile", ",", "(", "six", ".", "binary_type", ",", "six", ".", "text_type", ")", ")", ":", "infile", "=", "to_str", "(", "infile", ")", "original_path", ...
this overrides the original ConfigObj method of the same name. It runs through the input file collecting lines into a list. When completed, this method submits the list of lines to the super class' function of the same name. ConfigObj proceeds, completely unaware that it's input file ...
[ "this", "overrides", "the", "original", "ConfigObj", "method", "of", "the", "same", "name", ".", "It", "runs", "through", "the", "input", "file", "collecting", "lines", "into", "a", "list", ".", "When", "completed", "this", "method", "submits", "the", "list"...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/value_sources/for_configobj.py#L101-L116
mozilla/configman
configman/value_sources/for_configobj.py
ValueSource.get_values
def get_values(self, config_manager, ignore_mismatches, obj_hook=DotDict): """Return a nested dictionary representing the values in the ini file. In the case of this ValueSource implementation, both parameters are dummies.""" if self.delayed_parser_instantiation: try: ...
python
def get_values(self, config_manager, ignore_mismatches, obj_hook=DotDict): """Return a nested dictionary representing the values in the ini file. In the case of this ValueSource implementation, both parameters are dummies.""" if self.delayed_parser_instantiation: try: ...
[ "def", "get_values", "(", "self", ",", "config_manager", ",", "ignore_mismatches", ",", "obj_hook", "=", "DotDict", ")", ":", "if", "self", ".", "delayed_parser_instantiation", ":", "try", ":", "app", "=", "config_manager", ".", "_get_option", "(", "'admin.appli...
Return a nested dictionary representing the values in the ini file. In the case of this ValueSource implementation, both parameters are dummies.
[ "Return", "a", "nested", "dictionary", "representing", "the", "values", "in", "the", "ini", "file", ".", "In", "the", "case", "of", "this", "ValueSource", "implementation", "both", "parameters", "are", "dummies", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/value_sources/for_configobj.py#L168-L184
mozilla/configman
configman/value_sources/for_configobj.py
ValueSource._write_ini
def _write_ini(source_dict, namespace_name=None, level=0, indent_size=4, output_stream=sys.stdout): """this function prints the components of a configobj ini file. It is recursive for outputing the nested sections of the ini file.""" options = [ value ...
python
def _write_ini(source_dict, namespace_name=None, level=0, indent_size=4, output_stream=sys.stdout): """this function prints the components of a configobj ini file. It is recursive for outputing the nested sections of the ini file.""" options = [ value ...
[ "def", "_write_ini", "(", "source_dict", ",", "namespace_name", "=", "None", ",", "level", "=", "0", ",", "indent_size", "=", "4", ",", "output_stream", "=", "sys", ".", "stdout", ")", ":", "options", "=", "[", "value", "for", "value", "in", "source_dict...
this function prints the components of a configobj ini file. It is recursive for outputing the nested sections of the ini file.
[ "this", "function", "prints", "the", "components", "of", "a", "configobj", "ini", "file", ".", "It", "is", "recursive", "for", "outputing", "the", "nested", "sections", "of", "the", "ini", "file", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/value_sources/for_configobj.py#L202-L276
mozilla/configman
configman/__init__.py
configuration
def configuration(*args, **kwargs): """this function just instantiates a ConfigurationManager and returns the configuration dictionary. It accepts all the same parameters as the constructor for the ConfigurationManager class.""" try: config_kwargs = {'mapping_class': kwargs.pop('mapping_class')...
python
def configuration(*args, **kwargs): """this function just instantiates a ConfigurationManager and returns the configuration dictionary. It accepts all the same parameters as the constructor for the ConfigurationManager class.""" try: config_kwargs = {'mapping_class': kwargs.pop('mapping_class')...
[ "def", "configuration", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "config_kwargs", "=", "{", "'mapping_class'", ":", "kwargs", ".", "pop", "(", "'mapping_class'", ")", "}", "except", "KeyError", ":", "config_kwargs", "=", "{", "}",...
this function just instantiates a ConfigurationManager and returns the configuration dictionary. It accepts all the same parameters as the constructor for the ConfigurationManager class.
[ "this", "function", "just", "instantiates", "a", "ConfigurationManager", "and", "returns", "the", "configuration", "dictionary", ".", "It", "accepts", "all", "the", "same", "parameters", "as", "the", "constructor", "for", "the", "ConfigurationManager", "class", "." ...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/__init__.py#L38-L47
mozilla/configman
configman/value_sources/for_argparse.py
IntermediateConfigmanParser.error
def error(self, message): """we need to suppress errors that might happen in earlier phases of the expansion/overlay process. """ if ( "not allowed" in message or "ignored" in message or "expected" in message or "invalid" in message or ...
python
def error(self, message): """we need to suppress errors that might happen in earlier phases of the expansion/overlay process. """ if ( "not allowed" in message or "ignored" in message or "expected" in message or "invalid" in message or ...
[ "def", "error", "(", "self", ",", "message", ")", ":", "if", "(", "\"not allowed\"", "in", "message", "or", "\"ignored\"", "in", "message", "or", "\"expected\"", "in", "message", "or", "\"invalid\"", "in", "message", "or", "self", ".", "add_help", ")", ":"...
we need to suppress errors that might happen in earlier phases of the expansion/overlay process.
[ "we", "need", "to", "suppress", "errors", "that", "might", "happen", "in", "earlier", "phases", "of", "the", "expansion", "/", "overlay", "process", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/value_sources/for_argparse.py#L83-L96
mozilla/configman
configman/dotdict.py
iteritems_breadth_first
def iteritems_breadth_first(a_mapping, include_dicts=False): """a generator that returns all the keys in a set of nested Mapping instances. The keys take the form X.Y.Z""" subordinate_mappings = [] for key, value in six.iteritems(a_mapping): if isinstance(value, collections.Mapping): ...
python
def iteritems_breadth_first(a_mapping, include_dicts=False): """a generator that returns all the keys in a set of nested Mapping instances. The keys take the form X.Y.Z""" subordinate_mappings = [] for key, value in six.iteritems(a_mapping): if isinstance(value, collections.Mapping): ...
[ "def", "iteritems_breadth_first", "(", "a_mapping", ",", "include_dicts", "=", "False", ")", ":", "subordinate_mappings", "=", "[", "]", "for", "key", ",", "value", "in", "six", ".", "iteritems", "(", "a_mapping", ")", ":", "if", "isinstance", "(", "value", ...
a generator that returns all the keys in a set of nested Mapping instances. The keys take the form X.Y.Z
[ "a", "generator", "that", "returns", "all", "the", "keys", "in", "a", "set", "of", "nested", "Mapping", "instances", ".", "The", "keys", "take", "the", "form", "X", ".", "Y", ".", "Z" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/dotdict.py#L15-L28
mozilla/configman
configman/dotdict.py
configman_keys
def configman_keys(a_mapping): """return a DotDict that is a copy of the provided mapping with keys transformed into a configman compatible form: if the key is not all uppercase then all doubled underscores will be replaced with the '.' character. This has a specific use with the os.en...
python
def configman_keys(a_mapping): """return a DotDict that is a copy of the provided mapping with keys transformed into a configman compatible form: if the key is not all uppercase then all doubled underscores will be replaced with the '.' character. This has a specific use with the os.en...
[ "def", "configman_keys", "(", "a_mapping", ")", ":", "configmanized_keys_dict", "=", "DotDict", "(", ")", "for", "k", ",", "v", "in", "iteritems_breadth_first", "(", "a_mapping", ")", ":", "if", "'__'", "in", "k", "and", "k", "!=", "k", ".", "upper", "("...
return a DotDict that is a copy of the provided mapping with keys transformed into a configman compatible form: if the key is not all uppercase then all doubled underscores will be replaced with the '.' character. This has a specific use with the os.environ. Linux shells generally do not ...
[ "return", "a", "DotDict", "that", "is", "a", "copy", "of", "the", "provided", "mapping", "with", "keys", "transformed", "into", "a", "configman", "compatible", "form", ":", "if", "the", "key", "is", "not", "all", "uppercase", "then", "all", "doubled", "und...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/dotdict.py#L32-L50
mozilla/configman
configman/dotdict.py
create_key_translating_dot_dict
def create_key_translating_dot_dict( new_class_name, translation_tuples, base_class=DotDict ): """this function will generate a DotDict derivative class that has key translation built in. If the key is not found, translations (as specified by the translation_tuples) are performed on the key and...
python
def create_key_translating_dot_dict( new_class_name, translation_tuples, base_class=DotDict ): """this function will generate a DotDict derivative class that has key translation built in. If the key is not found, translations (as specified by the translation_tuples) are performed on the key and...
[ "def", "create_key_translating_dot_dict", "(", "new_class_name", ",", "translation_tuples", ",", "base_class", "=", "DotDict", ")", ":", "#==========================================================================", "class", "DotDictWithKeyTranslations", "(", "base_class", ")", "...
this function will generate a DotDict derivative class that has key translation built in. If the key is not found, translations (as specified by the translation_tuples) are performed on the key and the lookup is tried again. Only on failure of this second lookup will the KeyError exception be raised. ...
[ "this", "function", "will", "generate", "a", "DotDict", "derivative", "class", "that", "has", "key", "translation", "built", "in", ".", "If", "the", "key", "is", "not", "found", "translations", "(", "as", "specified", "by", "the", "translation_tuples", ")", ...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/dotdict.py#L367-L431
mozilla/configman
configman/dotdict.py
DotDict.keys_breadth_first
def keys_breadth_first(self, include_dicts=False): """a generator that returns all the keys in a set of nested DotDict instances. The keys take the form X.Y.Z""" namespaces = [] for key in self._key_order: if isinstance(getattr(self, key), DotDict): namespace...
python
def keys_breadth_first(self, include_dicts=False): """a generator that returns all the keys in a set of nested DotDict instances. The keys take the form X.Y.Z""" namespaces = [] for key in self._key_order: if isinstance(getattr(self, key), DotDict): namespace...
[ "def", "keys_breadth_first", "(", "self", ",", "include_dicts", "=", "False", ")", ":", "namespaces", "=", "[", "]", "for", "key", "in", "self", ".", "_key_order", ":", "if", "isinstance", "(", "getattr", "(", "self", ",", "key", ")", ",", "DotDict", "...
a generator that returns all the keys in a set of nested DotDict instances. The keys take the form X.Y.Z
[ "a", "generator", "that", "returns", "all", "the", "keys", "in", "a", "set", "of", "nested", "DotDict", "instances", ".", "The", "keys", "take", "the", "form", "X", ".", "Y", ".", "Z" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/dotdict.py#L207-L220
mozilla/configman
configman/dotdict.py
DotDict.assign
def assign(self, key, value): """an alternative method for assigning values to nested DotDict instances. It accepts keys in the form of X.Y.Z. If any nested DotDict instances don't yet exist, they will be created.""" key_split = key.split('.') cur_dict = self for k in k...
python
def assign(self, key, value): """an alternative method for assigning values to nested DotDict instances. It accepts keys in the form of X.Y.Z. If any nested DotDict instances don't yet exist, they will be created.""" key_split = key.split('.') cur_dict = self for k in k...
[ "def", "assign", "(", "self", ",", "key", ",", "value", ")", ":", "key_split", "=", "key", ".", "split", "(", "'.'", ")", "cur_dict", "=", "self", "for", "k", "in", "key_split", "[", ":", "-", "1", "]", ":", "try", ":", "cur_dict", "=", "cur_dict...
an alternative method for assigning values to nested DotDict instances. It accepts keys in the form of X.Y.Z. If any nested DotDict instances don't yet exist, they will be created.
[ "an", "alternative", "method", "for", "assigning", "values", "to", "nested", "DotDict", "instances", ".", "It", "accepts", "keys", "in", "the", "form", "of", "X", ".", "Y", ".", "Z", ".", "If", "any", "nested", "DotDict", "instances", "don", "t", "yet", ...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/dotdict.py#L223-L236
mozilla/configman
configman/dotdict.py
DotDict.parent
def parent(self, key): """when given a key of the form X.Y.Z, this method will return the parent DotDict of the 'Z' key.""" parent_key = '.'.join(key.split('.')[:-1]) if not parent_key: return None else: return self[parent_key]
python
def parent(self, key): """when given a key of the form X.Y.Z, this method will return the parent DotDict of the 'Z' key.""" parent_key = '.'.join(key.split('.')[:-1]) if not parent_key: return None else: return self[parent_key]
[ "def", "parent", "(", "self", ",", "key", ")", ":", "parent_key", "=", "'.'", ".", "join", "(", "key", ".", "split", "(", "'.'", ")", "[", ":", "-", "1", "]", ")", "if", "not", "parent_key", ":", "return", "None", "else", ":", "return", "self", ...
when given a key of the form X.Y.Z, this method will return the parent DotDict of the 'Z' key.
[ "when", "given", "a", "key", "of", "the", "form", "X", ".", "Y", ".", "Z", "this", "method", "will", "return", "the", "parent", "DotDict", "of", "the", "Z", "key", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/dotdict.py#L239-L246
mozilla/configman
configman/memoize.py
memoize
def memoize(max_cache_size=1000): """Python 2.4 compatible memoize decorator. It creates a cache that has a maximum size. If the cache exceeds the max, it is thrown out and a new one made. With such behavior, it is wise to set the cache just a little larger that the maximum expected need. Paramet...
python
def memoize(max_cache_size=1000): """Python 2.4 compatible memoize decorator. It creates a cache that has a maximum size. If the cache exceeds the max, it is thrown out and a new one made. With such behavior, it is wise to set the cache just a little larger that the maximum expected need. Paramet...
[ "def", "memoize", "(", "max_cache_size", "=", "1000", ")", ":", "def", "wrapper", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "fn", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ":", "key", "=", "(", "args", ...
Python 2.4 compatible memoize decorator. It creates a cache that has a maximum size. If the cache exceeds the max, it is thrown out and a new one made. With such behavior, it is wise to set the cache just a little larger that the maximum expected need. Parameters: max_cache_size - the size to w...
[ "Python", "2", ".", "4", "compatible", "memoize", "decorator", ".", "It", "creates", "a", "cache", "that", "has", "a", "maximum", "size", ".", "If", "the", "cache", "exceeds", "the", "max", "it", "is", "thrown", "out", "and", "a", "new", "one", "made",...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/memoize.py#L9-L40
mozilla/configman
configman/option.py
Option.set_default
def set_default(self, val, force=False): """this function allows a default to be set on an option that dosen't have one. It is used when a base class defines an Option for use in derived classes but cannot predict what value would useful to the derived classes. This gives the derived c...
python
def set_default(self, val, force=False): """this function allows a default to be set on an option that dosen't have one. It is used when a base class defines an Option for use in derived classes but cannot predict what value would useful to the derived classes. This gives the derived c...
[ "def", "set_default", "(", "self", ",", "val", ",", "force", "=", "False", ")", ":", "if", "self", ".", "default", "is", "None", "or", "force", ":", "self", ".", "default", "=", "val", "self", ".", "set_value", "(", "val", ")", "self", ".", "has_ch...
this function allows a default to be set on an option that dosen't have one. It is used when a base class defines an Option for use in derived classes but cannot predict what value would useful to the derived classes. This gives the derived classes the opportunity to set a logical defa...
[ "this", "function", "allows", "a", "default", "to", "be", "set", "on", "an", "option", "that", "dosen", "t", "have", "one", ".", "It", "is", "used", "when", "a", "base", "class", "defines", "an", "Option", "for", "use", "in", "derived", "classes", "but...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/option.py#L147-L180
mozilla/configman
configman/option.py
Option.copy
def copy(self): """return a copy""" o = Option( name=self.name, default=self.default, doc=self.doc, from_string_converter=self.from_string_converter, to_string_converter=self.to_string_converter, value=self.value, short_...
python
def copy(self): """return a copy""" o = Option( name=self.name, default=self.default, doc=self.doc, from_string_converter=self.from_string_converter, to_string_converter=self.to_string_converter, value=self.value, short_...
[ "def", "copy", "(", "self", ")", ":", "o", "=", "Option", "(", "name", "=", "self", ".", "name", ",", "default", "=", "self", ".", "default", ",", "doc", "=", "self", ".", "doc", ",", "from_string_converter", "=", "self", ".", "from_string_converter", ...
return a copy
[ "return", "a", "copy" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/option.py#L183-L203
mozilla/configman
configman/config_manager.py
ConfigurationManager.context
def context(self, mapping_class=DotDictWithAcquisition): """return a config as a context that calls close on every item when it goes out of scope""" config = None try: config = self.get_config(mapping_class=mapping_class) yield config finally: ...
python
def context(self, mapping_class=DotDictWithAcquisition): """return a config as a context that calls close on every item when it goes out of scope""" config = None try: config = self.get_config(mapping_class=mapping_class) yield config finally: ...
[ "def", "context", "(", "self", ",", "mapping_class", "=", "DotDictWithAcquisition", ")", ":", "config", "=", "None", "try", ":", "config", "=", "self", ".", "get_config", "(", "mapping_class", "=", "mapping_class", ")", "yield", "config", "finally", ":", "if...
return a config as a context that calls close on every item when it goes out of scope
[ "return", "a", "config", "as", "a", "context", "that", "calls", "close", "on", "every", "item", "when", "it", "goes", "out", "of", "scope" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/config_manager.py#L320-L329
mozilla/configman
configman/config_manager.py
ConfigurationManager.output_summary
def output_summary(self, output_stream=sys.stdout): """outputs a usage tip and the list of acceptable commands. This is useful as the output of the 'help' option. parameters: output_stream - an open file-like object suitable for use as the target of a pri...
python
def output_summary(self, output_stream=sys.stdout): """outputs a usage tip and the list of acceptable commands. This is useful as the output of the 'help' option. parameters: output_stream - an open file-like object suitable for use as the target of a pri...
[ "def", "output_summary", "(", "self", ",", "output_stream", "=", "sys", ".", "stdout", ")", ":", "if", "self", ".", "app_name", "or", "self", ".", "app_description", ":", "print", "(", "'Application: '", ",", "end", "=", "''", ",", "file", "=", "output_s...
outputs a usage tip and the list of acceptable commands. This is useful as the output of the 'help' option. parameters: output_stream - an open file-like object suitable for use as the target of a print function
[ "outputs", "a", "usage", "tip", "and", "the", "list", "of", "acceptable", "commands", ".", "This", "is", "useful", "as", "the", "output", "of", "the", "help", "option", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/config_manager.py#L341-L425
mozilla/configman
configman/config_manager.py
ConfigurationManager.print_conf
def print_conf(self): """write a config file to the pathname specified in the parameter. The file extention determines the type of file written and must match a registered type. parameters: config_pathname - the full path and filename of the target config ...
python
def print_conf(self): """write a config file to the pathname specified in the parameter. The file extention determines the type of file written and must match a registered type. parameters: config_pathname - the full path and filename of the target config ...
[ "def", "print_conf", "(", "self", ")", ":", "config_file_type", "=", "self", ".", "_get_option", "(", "'admin.print_conf'", ")", ".", "value", "@", "contextlib", ".", "contextmanager", "def", "stdout_opener", "(", ")", ":", "yield", "sys", ".", "stdout", "sk...
write a config file to the pathname specified in the parameter. The file extention determines the type of file written and must match a registered type. parameters: config_pathname - the full path and filename of the target config file.
[ "write", "a", "config", "file", "to", "the", "pathname", "specified", "in", "the", "parameter", ".", "The", "file", "extention", "determines", "the", "type", "of", "file", "written", "and", "must", "match", "a", "registered", "type", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/config_manager.py#L428-L448
mozilla/configman
configman/config_manager.py
ConfigurationManager.dump_conf
def dump_conf(self, config_pathname=None): """write a config file to the pathname specified in the parameter. The file extention determines the type of file written and must match a registered type. parameters: config_pathname - the full path and filename of the target conf...
python
def dump_conf(self, config_pathname=None): """write a config file to the pathname specified in the parameter. The file extention determines the type of file written and must match a registered type. parameters: config_pathname - the full path and filename of the target conf...
[ "def", "dump_conf", "(", "self", ",", "config_pathname", "=", "None", ")", ":", "if", "not", "config_pathname", ":", "config_pathname", "=", "self", ".", "_get_option", "(", "'admin.dump_conf'", ")", ".", "value", "opener", "=", "functools", ".", "partial", ...
write a config file to the pathname specified in the parameter. The file extention determines the type of file written and must match a registered type. parameters: config_pathname - the full path and filename of the target config file.
[ "write", "a", "config", "file", "to", "the", "pathname", "specified", "in", "the", "parameter", ".", "The", "file", "extention", "determines", "the", "type", "of", "file", "written", "and", "must", "match", "a", "registered", "type", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/config_manager.py#L451-L472
mozilla/configman
configman/config_manager.py
ConfigurationManager.write_conf
def write_conf(self, config_file_type, opener, skip_keys=None): """write a configuration file to a file-like object. parameters: config_file_type - a string containing a registered file type OR a for_XXX module from the value_source ...
python
def write_conf(self, config_file_type, opener, skip_keys=None): """write a configuration file to a file-like object. parameters: config_file_type - a string containing a registered file type OR a for_XXX module from the value_source ...
[ "def", "write_conf", "(", "self", ",", "config_file_type", ",", "opener", ",", "skip_keys", "=", "None", ")", ":", "blocked_keys", "=", "self", ".", "keys_blocked_from_output", "if", "skip_keys", ":", "blocked_keys", ".", "extend", "(", "skip_keys", ")", "if",...
write a configuration file to a file-like object. parameters: config_file_type - a string containing a registered file type OR a for_XXX module from the value_source package. Passing in an string that is u...
[ "write", "a", "configuration", "file", "to", "a", "file", "-", "like", "object", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/config_manager.py#L475-L522
mozilla/configman
configman/config_manager.py
ConfigurationManager.log_config
def log_config(self, logger): """write out the current configuration to a log-like object. parameters: logger - a object that implements a method called 'info' with the same semantics as the call to 'logger.info'""" logger.info("app_name: %s", self.app_name) ...
python
def log_config(self, logger): """write out the current configuration to a log-like object. parameters: logger - a object that implements a method called 'info' with the same semantics as the call to 'logger.info'""" logger.info("app_name: %s", self.app_name) ...
[ "def", "log_config", "(", "self", ",", "logger", ")", ":", "logger", ".", "info", "(", "\"app_name: %s\"", ",", "self", ".", "app_name", ")", "logger", ".", "info", "(", "\"app_version: %s\"", ",", "self", ".", "app_version", ")", "logger", ".", "info", ...
write out the current configuration to a log-like object. parameters: logger - a object that implements a method called 'info' with the same semantics as the call to 'logger.info
[ "write", "out", "the", "current", "configuration", "to", "a", "log", "-", "like", "object", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/config_manager.py#L525-L550
mozilla/configman
configman/config_manager.py
ConfigurationManager.get_option_names
def get_option_names(self): """returns a list of fully qualified option names. returns: a list of strings representing the Options in the source Namespace list. Each item will be fully qualified with dot delimited Namespace names. """ return [x for x...
python
def get_option_names(self): """returns a list of fully qualified option names. returns: a list of strings representing the Options in the source Namespace list. Each item will be fully qualified with dot delimited Namespace names. """ return [x for x...
[ "def", "get_option_names", "(", "self", ")", ":", "return", "[", "x", "for", "x", "in", "self", ".", "option_definitions", ".", "keys_breadth_first", "(", ")", "if", "isinstance", "(", "self", ".", "option_definitions", "[", "x", "]", ",", "Option", ")", ...
returns a list of fully qualified option names. returns: a list of strings representing the Options in the source Namespace list. Each item will be fully qualified with dot delimited Namespace names.
[ "returns", "a", "list", "of", "fully", "qualified", "option", "names", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/config_manager.py#L553-L562
mozilla/configman
configman/config_manager.py
ConfigurationManager._create_reference_value_options
def _create_reference_value_options(self, keys, finished_keys): """this method steps through the option definitions looking for alt paths. On finding one, it creates the 'reference_value_from' links within the option definitions and populates it with copied options.""" # a set of known ...
python
def _create_reference_value_options(self, keys, finished_keys): """this method steps through the option definitions looking for alt paths. On finding one, it creates the 'reference_value_from' links within the option definitions and populates it with copied options.""" # a set of known ...
[ "def", "_create_reference_value_options", "(", "self", ",", "keys", ",", "finished_keys", ")", ":", "# a set of known reference_value_from_links", "set_of_reference_value_option_names", "=", "set", "(", ")", "for", "key", "in", "keys", ":", "if", "key", "in", "finishe...
this method steps through the option definitions looking for alt paths. On finding one, it creates the 'reference_value_from' links within the option definitions and populates it with copied options.
[ "this", "method", "steps", "through", "the", "option", "definitions", "looking", "for", "alt", "paths", ".", "On", "finding", "one", "it", "creates", "the", "reference_value_from", "links", "within", "the", "option", "definitions", "and", "populates", "it", "wit...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/config_manager.py#L565-L603
mozilla/configman
configman/config_manager.py
ConfigurationManager._overlay_expand
def _overlay_expand(self): """This method overlays each of the value sources onto the default in each of the defined options. It does so using a breadth first iteration, overlaying and expanding each level of the tree in turn. As soon as no changes were made to any level, the loop break...
python
def _overlay_expand(self): """This method overlays each of the value sources onto the default in each of the defined options. It does so using a breadth first iteration, overlaying and expanding each level of the tree in turn. As soon as no changes were made to any level, the loop break...
[ "def", "_overlay_expand", "(", "self", ")", ":", "new_keys_have_been_discovered", "=", "True", "# loop control, False breaks loop", "finished_keys", "=", "set", "(", ")", "all_reference_values", "=", "{", "}", "while", "new_keys_have_been_discovered", ":", "# loop until n...
This method overlays each of the value sources onto the default in each of the defined options. It does so using a breadth first iteration, overlaying and expanding each level of the tree in turn. As soon as no changes were made to any level, the loop breaks and the work is done. The a...
[ "This", "method", "overlays", "each", "of", "the", "value", "sources", "onto", "the", "default", "in", "each", "of", "the", "defined", "options", ".", "It", "does", "so", "using", "a", "breadth", "first", "iteration", "overlaying", "and", "expanding", "each"...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/config_manager.py#L606-L798
mozilla/configman
configman/config_manager.py
ConfigurationManager._check_for_mismatches
def _check_for_mismatches(self, known_keys): """check for bad options from value sources""" for a_value_source in self.values_source_list: try: if a_value_source.always_ignore_mismatches: continue except AttributeError: # ok, th...
python
def _check_for_mismatches(self, known_keys): """check for bad options from value sources""" for a_value_source in self.values_source_list: try: if a_value_source.always_ignore_mismatches: continue except AttributeError: # ok, th...
[ "def", "_check_for_mismatches", "(", "self", ",", "known_keys", ")", ":", "for", "a_value_source", "in", "self", ".", "values_source_list", ":", "try", ":", "if", "a_value_source", ".", "always_ignore_mismatches", ":", "continue", "except", "AttributeError", ":", ...
check for bad options from value sources
[ "check", "for", "bad", "options", "from", "value", "sources" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/config_manager.py#L801-L863
mozilla/configman
configman/config_manager.py
ConfigurationManager._generate_config
def _generate_config(self, mapping_class): """This routine generates a copy of the DotDict based config""" config = mapping_class() self._walk_config_copy_values( self.option_definitions, config, mapping_class ) return config
python
def _generate_config(self, mapping_class): """This routine generates a copy of the DotDict based config""" config = mapping_class() self._walk_config_copy_values( self.option_definitions, config, mapping_class ) return config
[ "def", "_generate_config", "(", "self", ",", "mapping_class", ")", ":", "config", "=", "mapping_class", "(", ")", "self", ".", "_walk_config_copy_values", "(", "self", ".", "option_definitions", ",", "config", ",", "mapping_class", ")", "return", "config" ]
This routine generates a copy of the DotDict based config
[ "This", "routine", "generates", "a", "copy", "of", "the", "DotDict", "based", "config" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/config_manager.py#L879-L887
mozilla/configman
demo/advanced_demo2.py
PGPooledTransaction.close
def close(self): """close all pooled connections""" print("PGPooledTransaction - shutting down connection pool") for name, conn in self.pool.iteritems(): conn.close() print("PGPooledTransaction - connection %s closed" % name)
python
def close(self): """close all pooled connections""" print("PGPooledTransaction - shutting down connection pool") for name, conn in self.pool.iteritems(): conn.close() print("PGPooledTransaction - connection %s closed" % name)
[ "def", "close", "(", "self", ")", ":", "print", "(", "\"PGPooledTransaction - shutting down connection pool\"", ")", "for", "name", ",", "conn", "in", "self", ".", "pool", ".", "iteritems", "(", ")", ":", "conn", ".", "close", "(", ")", "print", "(", "\"PG...
close all pooled connections
[ "close", "all", "pooled", "connections" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/demo/advanced_demo2.py#L182-L187
mozilla/configman
configman/def_sources/for_argparse.py
find_action_name_by_value
def find_action_name_by_value(registry, target_action_instance): """the association of a name of an action class with a human readable string is exposed externally only at the time of argument definitions. This routine, when given a reference to argparse's internal action registry and an action, will fi...
python
def find_action_name_by_value(registry, target_action_instance): """the association of a name of an action class with a human readable string is exposed externally only at the time of argument definitions. This routine, when given a reference to argparse's internal action registry and an action, will fi...
[ "def", "find_action_name_by_value", "(", "registry", ",", "target_action_instance", ")", ":", "target_type", "=", "type", "(", "target_action_instance", ")", "for", "key", ",", "value", "in", "six", ".", "iteritems", "(", "registry", "[", "'action'", "]", ")", ...
the association of a name of an action class with a human readable string is exposed externally only at the time of argument definitions. This routine, when given a reference to argparse's internal action registry and an action, will find that action and return the name under which it was registered.
[ "the", "association", "of", "a", "name", "of", "an", "action", "class", "with", "a", "human", "readable", "string", "is", "exposed", "externally", "only", "at", "the", "time", "of", "argument", "definitions", ".", "This", "routine", "when", "given", "a", "...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/def_sources/for_argparse.py#L39-L52
mozilla/configman
configman/def_sources/for_argparse.py
get_args_and_values
def get_args_and_values(parser, an_action): """this rountine attempts to reconstruct the kwargs that were used in the creation of an action object""" args = inspect.getargspec(an_action.__class__.__init__).args kwargs = dict( (an_attr, getattr(an_action, an_attr)) for an_attr in args ...
python
def get_args_and_values(parser, an_action): """this rountine attempts to reconstruct the kwargs that were used in the creation of an action object""" args = inspect.getargspec(an_action.__class__.__init__).args kwargs = dict( (an_attr, getattr(an_action, an_attr)) for an_attr in args ...
[ "def", "get_args_and_values", "(", "parser", ",", "an_action", ")", ":", "args", "=", "inspect", ".", "getargspec", "(", "an_action", ".", "__class__", ".", "__init__", ")", ".", "args", "kwargs", "=", "dict", "(", "(", "an_attr", ",", "getattr", "(", "a...
this rountine attempts to reconstruct the kwargs that were used in the creation of an action object
[ "this", "rountine", "attempts", "to", "reconstruct", "the", "kwargs", "that", "were", "used", "in", "the", "creation", "of", "an", "action", "object" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/def_sources/for_argparse.py#L56-L80
mozilla/configman
configman/def_sources/for_argparse.py
setup_definitions
def setup_definitions(source, destination): """this method stars the process of configman reading and using an argparse instance as a source of configuration definitions.""" #"""assume that source is of type argparse try: destination.update(source.get_required_config()) except AttributeError...
python
def setup_definitions(source, destination): """this method stars the process of configman reading and using an argparse instance as a source of configuration definitions.""" #"""assume that source is of type argparse try: destination.update(source.get_required_config()) except AttributeError...
[ "def", "setup_definitions", "(", "source", ",", "destination", ")", ":", "#\"\"\"assume that source is of type argparse", "try", ":", "destination", ".", "update", "(", "source", ".", "get_required_config", "(", ")", ")", "except", "AttributeError", ":", "# looks like...
this method stars the process of configman reading and using an argparse instance as a source of configuration definitions.
[ "this", "method", "stars", "the", "process", "of", "configman", "reading", "and", "using", "an", "argparse", "instance", "as", "a", "source", "of", "configuration", "definitions", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/def_sources/for_argparse.py#L662-L679
mozilla/configman
configman/def_sources/for_argparse.py
SubparserFromStringConverter.add_namespace
def add_namespace(self, name, a_namespace): """as we build up argparse, the actions that define a subparser are translated into configman options. Each of those options must be tagged with the value of the subparse to which they correspond.""" # save a local copy of the namespace ...
python
def add_namespace(self, name, a_namespace): """as we build up argparse, the actions that define a subparser are translated into configman options. Each of those options must be tagged with the value of the subparse to which they correspond.""" # save a local copy of the namespace ...
[ "def", "add_namespace", "(", "self", ",", "name", ",", "a_namespace", ")", ":", "# save a local copy of the namespace", "self", ".", "namespaces", "[", "name", "]", "=", "a_namespace", "# iterate through the namespace branding each of the options with the", "# name of the sub...
as we build up argparse, the actions that define a subparser are translated into configman options. Each of those options must be tagged with the value of the subparse to which they correspond.
[ "as", "we", "build", "up", "argparse", "the", "actions", "that", "define", "a", "subparser", "are", "translated", "into", "configman", "options", ".", "Each", "of", "those", "options", "must", "be", "tagged", "with", "the", "value", "of", "the", "subparse", ...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/def_sources/for_argparse.py#L98-L110
mozilla/configman
configman/def_sources/for_argparse.py
ConfigmanSubParsersAction.add_parser
def add_parser(self, *args, **kwargs): """each time a subparser action is used to create a new parser object we must save the original args & kwargs. In a later phase of configman, we'll need to reproduce the subparsers exactly without resorting to copying. We save the args & kwargs in...
python
def add_parser(self, *args, **kwargs): """each time a subparser action is used to create a new parser object we must save the original args & kwargs. In a later phase of configman, we'll need to reproduce the subparsers exactly without resorting to copying. We save the args & kwargs in...
[ "def", "add_parser", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "command_name", "=", "args", "[", "0", "]", "new_kwargs", "=", "kwargs", ".", "copy", "(", ")", "new_kwargs", "[", "'configman_subparsers_option'", "]", "=", "self", ...
each time a subparser action is used to create a new parser object we must save the original args & kwargs. In a later phase of configman, we'll need to reproduce the subparsers exactly without resorting to copying. We save the args & kwargs in the 'foreign_data' section of the configm...
[ "each", "time", "a", "subparser", "action", "is", "used", "to", "create", "a", "new", "parser", "object", "we", "must", "save", "the", "original", "args", "&", "kwargs", ".", "In", "a", "later", "phase", "of", "configman", "we", "ll", "need", "to", "re...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/def_sources/for_argparse.py#L171-L192
mozilla/configman
configman/def_sources/for_argparse.py
ArgumentParser.get_required_config
def get_required_config(self): """because of the exsistance of subparsers, the configman options that correspond with argparse arguments are not a constant. We need to produce a copy of the namespace rather than the actual embedded namespace.""" required_config = Namespace() ...
python
def get_required_config(self): """because of the exsistance of subparsers, the configman options that correspond with argparse arguments are not a constant. We need to produce a copy of the namespace rather than the actual embedded namespace.""" required_config = Namespace() ...
[ "def", "get_required_config", "(", "self", ")", ":", "required_config", "=", "Namespace", "(", ")", "# add current options to a copy of required config", "for", "k", ",", "v", "in", "iteritems_breadth_first", "(", "self", ".", "required_config", ")", ":", "required_co...
because of the exsistance of subparsers, the configman options that correspond with argparse arguments are not a constant. We need to produce a copy of the namespace rather than the actual embedded namespace.
[ "because", "of", "the", "exsistance", "of", "subparsers", "the", "configman", "options", "that", "correspond", "with", "argparse", "arguments", "are", "not", "a", "constant", ".", "We", "need", "to", "produce", "a", "copy", "of", "the", "namespace", "rather", ...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/def_sources/for_argparse.py#L226-L257
mozilla/configman
configman/def_sources/for_argparse.py
ArgumentParser.add_argument
def add_argument(self, *args, **kwargs): """this method overrides the standard in order to create a parallel argument system in both the argparse and configman worlds. Each call to this method returns a standard argparse Action object as well as adding an equivalent configman Option obj...
python
def add_argument(self, *args, **kwargs): """this method overrides the standard in order to create a parallel argument system in both the argparse and configman worlds. Each call to this method returns a standard argparse Action object as well as adding an equivalent configman Option obj...
[ "def", "add_argument", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# pull out each of the argument definition components from the args", "# so that we can deal with them one at a time in a well labeled manner", "# In this section, variables beginning with the pre...
this method overrides the standard in order to create a parallel argument system in both the argparse and configman worlds. Each call to this method returns a standard argparse Action object as well as adding an equivalent configman Option object to the required_config for this object. ...
[ "this", "method", "overrides", "the", "standard", "in", "order", "to", "create", "a", "parallel", "argument", "system", "in", "both", "the", "argparse", "and", "configman", "worlds", ".", "Each", "call", "to", "this", "method", "returns", "a", "standard", "a...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/def_sources/for_argparse.py#L260-L501
mozilla/configman
configman/def_sources/for_argparse.py
ArgumentParser.add_subparsers
def add_subparsers(self, *args, **kwargs): """When adding a subparser, we need to ensure that our version of the SubparserAction object is returned. We also need to create the corresponding configman Option object for the subparser and pack it's foreign data section with the original ar...
python
def add_subparsers(self, *args, **kwargs): """When adding a subparser, we need to ensure that our version of the SubparserAction object is returned. We also need to create the corresponding configman Option object for the subparser and pack it's foreign data section with the original ar...
[ "def", "add_subparsers", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'parser_class'", "]", "=", "self", ".", "__class__", "kwargs", "[", "'action'", "]", "=", "ConfigmanSubParsersAction", "subparser_action", "=", "super"...
When adding a subparser, we need to ensure that our version of the SubparserAction object is returned. We also need to create the corresponding configman Option object for the subparser and pack it's foreign data section with the original args & kwargs.
[ "When", "adding", "a", "subparser", "we", "need", "to", "ensure", "that", "our", "version", "of", "the", "SubparserAction", "object", "is", "returned", ".", "We", "also", "need", "to", "create", "the", "corresponding", "configman", "Option", "object", "for", ...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/def_sources/for_argparse.py#L504-L556
mozilla/configman
configman/def_sources/for_argparse.py
ArgumentParser.parse_args
def parse_args(self, args=None, namespace=None): """this method hijacks the normal argparse Namespace generation, shimming configman into the process. The return value will be a configman DotDict rather than an argparse Namespace.""" # load the config_manager within the scope of the meth...
python
def parse_args(self, args=None, namespace=None): """this method hijacks the normal argparse Namespace generation, shimming configman into the process. The return value will be a configman DotDict rather than an argparse Namespace.""" # load the config_manager within the scope of the meth...
[ "def", "parse_args", "(", "self", ",", "args", "=", "None", ",", "namespace", "=", "None", ")", ":", "# load the config_manager within the scope of the method that uses it", "# so that we avoid circular references in the outer scope", "from", "configman", ".", "config_manager",...
this method hijacks the normal argparse Namespace generation, shimming configman into the process. The return value will be a configman DotDict rather than an argparse Namespace.
[ "this", "method", "hijacks", "the", "normal", "argparse", "Namespace", "generation", "shimming", "configman", "into", "the", "process", ".", "The", "return", "value", "will", "be", "a", "configman", "DotDict", "rather", "than", "an", "argparse", "Namespace", "."...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/def_sources/for_argparse.py#L566-L615
mozilla/configman
configman/def_sources/for_argparse.py
ArgumentParser.parse_known_args
def parse_known_args(self, args=None, namespace=None): """this method hijacks the normal argparse Namespace generation, shimming configman into the process. The return value will be a configman DotDict rather than an argparse Namespace.""" # load the config_manager within the scope of th...
python
def parse_known_args(self, args=None, namespace=None): """this method hijacks the normal argparse Namespace generation, shimming configman into the process. The return value will be a configman DotDict rather than an argparse Namespace.""" # load the config_manager within the scope of th...
[ "def", "parse_known_args", "(", "self", ",", "args", "=", "None", ",", "namespace", "=", "None", ")", ":", "# load the config_manager within the scope of the method that uses it", "# so that we avoid circular references in the outer scope", "from", "configman", ".", "config_man...
this method hijacks the normal argparse Namespace generation, shimming configman into the process. The return value will be a configman DotDict rather than an argparse Namespace.
[ "this", "method", "hijacks", "the", "normal", "argparse", "Namespace", "generation", "shimming", "configman", "into", "the", "process", ".", "The", "return", "value", "will", "be", "a", "configman", "DotDict", "rather", "than", "an", "argparse", "Namespace", "."...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/def_sources/for_argparse.py#L618-L640
mozilla/configman
configman/value_sources/for_modules.py
sequence_to_string
def sequence_to_string( a_list, open_bracket_char='[', close_bracket_char=']', delimiter=", " ): """a dedicated function that turns a list into a comma delimited string of items converted. This method will flatten nested lists.""" return "%s%s%s" % ( open_bracket_char, delim...
python
def sequence_to_string( a_list, open_bracket_char='[', close_bracket_char=']', delimiter=", " ): """a dedicated function that turns a list into a comma delimited string of items converted. This method will flatten nested lists.""" return "%s%s%s" % ( open_bracket_char, delim...
[ "def", "sequence_to_string", "(", "a_list", ",", "open_bracket_char", "=", "'['", ",", "close_bracket_char", "=", "']'", ",", "delimiter", "=", "\", \"", ")", ":", "return", "\"%s%s%s\"", "%", "(", "open_bracket_char", ",", "delimiter", ".", "join", "(", "loca...
a dedicated function that turns a list into a comma delimited string of items converted. This method will flatten nested lists.
[ "a", "dedicated", "function", "that", "turns", "a", "list", "into", "a", "comma", "delimited", "string", "of", "items", "converted", ".", "This", "method", "will", "flatten", "nested", "lists", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/value_sources/for_modules.py#L61-L76
mozilla/configman
configman/value_sources/for_modules.py
get_import_for_type
def get_import_for_type(t): """given a type, return a tuple of the (module-path, type_name) or (None, None) if it is a built in.""" t_as_string = to_str(t) if not is_identifier(t_as_string): # this class expanded into something other than a single identifier # we can ignore it. This is ...
python
def get_import_for_type(t): """given a type, return a tuple of the (module-path, type_name) or (None, None) if it is a built in.""" t_as_string = to_str(t) if not is_identifier(t_as_string): # this class expanded into something other than a single identifier # we can ignore it. This is ...
[ "def", "get_import_for_type", "(", "t", ")", ":", "t_as_string", "=", "to_str", "(", "t", ")", "if", "not", "is_identifier", "(", "t_as_string", ")", ":", "# this class expanded into something other than a single identifier", "# we can ignore it. This is the case when we enc...
given a type, return a tuple of the (module-path, type_name) or (None, None) if it is a built in.
[ "given", "a", "type", "return", "a", "tuple", "of", "the", "(", "module", "-", "path", "type_name", ")", "or", "(", "None", "None", ")", "if", "it", "is", "a", "built", "in", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/value_sources/for_modules.py#L145-L161
mozilla/configman
configman/value_sources/for_modules.py
ValueSource.write
def write(source_mapping, output_stream=sys.stdout): """This method writes a Python module respresenting all the keys and values known to configman. """ # a set of classes, modules and/or functions that are values in # configman options. These values will have to be imported in ...
python
def write(source_mapping, output_stream=sys.stdout): """This method writes a Python module respresenting all the keys and values known to configman. """ # a set of classes, modules and/or functions that are values in # configman options. These values will have to be imported in ...
[ "def", "write", "(", "source_mapping", ",", "output_stream", "=", "sys", ".", "stdout", ")", ":", "# a set of classes, modules and/or functions that are values in", "# configman options. These values will have to be imported in the", "# module that this method is writing.", "set_of_cl...
This method writes a Python module respresenting all the keys and values known to configman.
[ "This", "method", "writes", "a", "Python", "module", "respresenting", "all", "the", "keys", "and", "values", "known", "to", "configman", "." ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/value_sources/for_modules.py#L329-L532
mozilla/configman
configman/datetime_util.py
datetime_from_ISO_string
def datetime_from_ISO_string(s): """ Take an ISO date string of the form YYYY-MM-DDTHH:MM:SS.S and convert it into an instance of datetime.datetime """ try: return datetime.datetime.strptime(s, '%Y-%m-%dT%H:%M:%S') except ValueError: try: return datetime.datetime.strptime...
python
def datetime_from_ISO_string(s): """ Take an ISO date string of the form YYYY-MM-DDTHH:MM:SS.S and convert it into an instance of datetime.datetime """ try: return datetime.datetime.strptime(s, '%Y-%m-%dT%H:%M:%S') except ValueError: try: return datetime.datetime.strptime...
[ "def", "datetime_from_ISO_string", "(", "s", ")", ":", "try", ":", "return", "datetime", ".", "datetime", ".", "strptime", "(", "s", ",", "'%Y-%m-%dT%H:%M:%S'", ")", "except", "ValueError", ":", "try", ":", "return", "datetime", ".", "datetime", ".", "strpti...
Take an ISO date string of the form YYYY-MM-DDTHH:MM:SS.S and convert it into an instance of datetime.datetime
[ "Take", "an", "ISO", "date", "string", "of", "the", "form", "YYYY", "-", "MM", "-", "DDTHH", ":", "MM", ":", "SS", ".", "S", "and", "convert", "it", "into", "an", "instance", "of", "datetime", ".", "datetime" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/datetime_util.py#L9-L19
mozilla/configman
configman/datetime_util.py
str_to_timedelta
def str_to_timedelta(input_str): """ a string conversion function for timedelta for strings in the format DD:HH:MM:SS or D HH:MM:SS """ try: input_str = input_str.replace(' ', ':') except (TypeError, AttributeError): from configman.converters import to_str raise TypeError('%s...
python
def str_to_timedelta(input_str): """ a string conversion function for timedelta for strings in the format DD:HH:MM:SS or D HH:MM:SS """ try: input_str = input_str.replace(' ', ':') except (TypeError, AttributeError): from configman.converters import to_str raise TypeError('%s...
[ "def", "str_to_timedelta", "(", "input_str", ")", ":", "try", ":", "input_str", "=", "input_str", ".", "replace", "(", "' '", ",", "':'", ")", "except", "(", "TypeError", ",", "AttributeError", ")", ":", "from", "configman", ".", "converters", "import", "t...
a string conversion function for timedelta for strings in the format DD:HH:MM:SS or D HH:MM:SS
[ "a", "string", "conversion", "function", "for", "timedelta", "for", "strings", "in", "the", "format", "DD", ":", "HH", ":", "MM", ":", "SS", "or", "D", "HH", ":", "MM", ":", "SS" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/datetime_util.py#L49-L71
mozilla/configman
configman/datetime_util.py
timedelta_to_str
def timedelta_to_str(aTimedelta): """ a conversion function for time deltas to string in the form DD:HH:MM:SS """ days = aTimedelta.days temp_seconds = aTimedelta.seconds hours = int(temp_seconds / 3600) minutes = int((temp_seconds - hours * 3600) / 60) seconds = temp_seconds - hours * 3...
python
def timedelta_to_str(aTimedelta): """ a conversion function for time deltas to string in the form DD:HH:MM:SS """ days = aTimedelta.days temp_seconds = aTimedelta.seconds hours = int(temp_seconds / 3600) minutes = int((temp_seconds - hours * 3600) / 60) seconds = temp_seconds - hours * 3...
[ "def", "timedelta_to_str", "(", "aTimedelta", ")", ":", "days", "=", "aTimedelta", ".", "days", "temp_seconds", "=", "aTimedelta", ".", "seconds", "hours", "=", "int", "(", "temp_seconds", "/", "3600", ")", "minutes", "=", "int", "(", "(", "temp_seconds", ...
a conversion function for time deltas to string in the form DD:HH:MM:SS
[ "a", "conversion", "function", "for", "time", "deltas", "to", "string", "in", "the", "form", "DD", ":", "HH", ":", "MM", ":", "SS" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/datetime_util.py#L74-L83
Chris7/django-djangui
djangui/backend/ast/source_parser.py
parse_source_file
def parse_source_file(file_name): """ Parses the AST of Python file for lines containing references to the argparse module. returns the collection of ast objects found. Example client code: 1. parser = ArgumentParser(desc="My help Message") 2. parser.add_argument('filename', help="Nam...
python
def parse_source_file(file_name): """ Parses the AST of Python file for lines containing references to the argparse module. returns the collection of ast objects found. Example client code: 1. parser = ArgumentParser(desc="My help Message") 2. parser.add_argument('filename', help="Nam...
[ "def", "parse_source_file", "(", "file_name", ")", ":", "with", "open", "(", "file_name", ",", "'r'", ")", "as", "f", ":", "s", "=", "f", ".", "read", "(", ")", "nodes", "=", "ast", ".", "parse", "(", "s", ")", "module_imports", "=", "get_nodes_by_in...
Parses the AST of Python file for lines containing references to the argparse module. returns the collection of ast objects found. Example client code: 1. parser = ArgumentParser(desc="My help Message") 2. parser.add_argument('filename', help="Name of the file to load") 3. parser.add_ar...
[ "Parses", "the", "AST", "of", "Python", "file", "for", "lines", "containing", "references", "to", "the", "argparse", "module", "." ]
train
https://github.com/Chris7/django-djangui/blob/4e9e37ac92e128dbaa0c809e5e33618d2c96808f/djangui/backend/ast/source_parser.py#L17-L83
mozilla/configman
configman/value_sources/for_getopt.py
ValueSource.get_values
def get_values(self, config_manager, ignore_mismatches, obj_hook=DotDict): """This is the black sheep of the crowd of ValueSource implementations. It needs to know ahead of time all of the parameters that it will need, but we cannot give it. We may not know all the parameters because no...
python
def get_values(self, config_manager, ignore_mismatches, obj_hook=DotDict): """This is the black sheep of the crowd of ValueSource implementations. It needs to know ahead of time all of the parameters that it will need, but we cannot give it. We may not know all the parameters because no...
[ "def", "get_values", "(", "self", ",", "config_manager", ",", "ignore_mismatches", ",", "obj_hook", "=", "DotDict", ")", ":", "short_options_str", ",", "long_options_list", "=", "self", ".", "getopt_create_opts", "(", "config_manager", ".", "option_definitions", ")"...
This is the black sheep of the crowd of ValueSource implementations. It needs to know ahead of time all of the parameters that it will need, but we cannot give it. We may not know all the parameters because not all classes may have been expanded yet. The two parameters allow this Value...
[ "This", "is", "the", "black", "sheep", "of", "the", "crowd", "of", "ValueSource", "implementations", ".", "It", "needs", "to", "know", "ahead", "of", "time", "all", "of", "the", "parameters", "that", "it", "will", "need", "but", "we", "cannot", "give", "...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/value_sources/for_getopt.py#L64-L124
mozilla/configman
configman/value_sources/for_getopt.py
ValueSource.getopt_with_ignore
def getopt_with_ignore(args, shortopts, longopts=[]): """my_getopt(args, options[, long_options]) -> opts, args This function works like gnu_getopt(), except that unknown parameters are ignored rather than raising an error. """ opts = [] prog_args = [] if isinsta...
python
def getopt_with_ignore(args, shortopts, longopts=[]): """my_getopt(args, options[, long_options]) -> opts, args This function works like gnu_getopt(), except that unknown parameters are ignored rather than raising an error. """ opts = [] prog_args = [] if isinsta...
[ "def", "getopt_with_ignore", "(", "args", ",", "shortopts", ",", "longopts", "=", "[", "]", ")", ":", "opts", "=", "[", "]", "prog_args", "=", "[", "]", "if", "isinstance", "(", "longopts", ",", "str", ")", ":", "longopts", "=", "[", "longopts", "]",...
my_getopt(args, options[, long_options]) -> opts, args This function works like gnu_getopt(), except that unknown parameters are ignored rather than raising an error.
[ "my_getopt", "(", "args", "options", "[", "long_options", "]", ")", "-", ">", "opts", "args" ]
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/value_sources/for_getopt.py#L171-L210
mozilla/configman
configman/namespace.py
Namespace.add_option
def add_option(self, name, *args, **kwargs): """add an option to the namespace. This can take two forms: 'name' is a string representing the name of an option and the kwargs are its parameters, or 'name' is an instance of an Option object """ if isinst...
python
def add_option(self, name, *args, **kwargs): """add an option to the namespace. This can take two forms: 'name' is a string representing the name of an option and the kwargs are its parameters, or 'name' is an instance of an Option object """ if isinst...
[ "def", "add_option", "(", "self", ",", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "name", ",", "Option", ")", ":", "an_option", "=", "name", "name", "=", "an_option", ".", "name", "else", ":", "an_option", ...
add an option to the namespace. This can take two forms: 'name' is a string representing the name of an option and the kwargs are its parameters, or 'name' is an instance of an Option object
[ "add", "an", "option", "to", "the", "namespace", ".", "This", "can", "take", "two", "forms", ":", "name", "is", "a", "string", "representing", "the", "name", "of", "an", "option", "and", "the", "kwargs", "are", "its", "parameters", "or", "name", "is", ...
train
https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/namespace.py#L31-L52
Gscorreia89/pyChemometrics
pyChemometrics/ChemometricsPLS_LDA.py
ChemometricsPLS_LDA._cummulativefit
def _cummulativefit(self, x, y): """ Measure the cumulative Regression sum of Squares for each individual component. :param x: Data matrix to fit the PLS model. :type x: numpy.ndarray, shape [n_samples, n_features] :param y: Data matrix to fit the PLS model. :type y: num...
python
def _cummulativefit(self, x, y): """ Measure the cumulative Regression sum of Squares for each individual component. :param x: Data matrix to fit the PLS model. :type x: numpy.ndarray, shape [n_samples, n_features] :param y: Data matrix to fit the PLS model. :type y: num...
[ "def", "_cummulativefit", "(", "self", ",", "x", ",", "y", ")", ":", "if", "y", ".", "ndim", "==", "1", ":", "y", "=", "y", ".", "reshape", "(", "-", "1", ",", "1", ")", "if", "x", ".", "ndim", "==", "1", ":", "x", "=", "x", ".", "reshape...
Measure the cumulative Regression sum of Squares for each individual component. :param x: Data matrix to fit the PLS model. :type x: numpy.ndarray, shape [n_samples, n_features] :param y: Data matrix to fit the PLS model. :type y: numpy.ndarray, shape [n_samples, n_features] :re...
[ "Measure", "the", "cumulative", "Regression", "sum", "of", "Squares", "for", "each", "individual", "component", "." ]
train
https://github.com/Gscorreia89/pyChemometrics/blob/539f5cd719795685271faa7fb1c6d53d7dd4de19/pyChemometrics/ChemometricsPLS_LDA.py#L955-L996
Gscorreia89/pyChemometrics
pyChemometrics/PCAPlotMixin.py
PCAPlotMixin.plot_leverages
def plot_leverages(self): """ Leverage (h) per observation, with a red line plotted at y = 1/Number of samples (expected :return: Plot with observation leverages (h) """ plt.figure() lev = self.leverages() plt.xlabel('Sample Index') plt.ylabel('Leverage') ...
python
def plot_leverages(self): """ Leverage (h) per observation, with a red line plotted at y = 1/Number of samples (expected :return: Plot with observation leverages (h) """ plt.figure() lev = self.leverages() plt.xlabel('Sample Index') plt.ylabel('Leverage') ...
[ "def", "plot_leverages", "(", "self", ")", ":", "plt", ".", "figure", "(", ")", "lev", "=", "self", ".", "leverages", "(", ")", "plt", ".", "xlabel", "(", "'Sample Index'", ")", "plt", ".", "ylabel", "(", "'Leverage'", ")", "plt", ".", "bar", "(", ...
Leverage (h) per observation, with a red line plotted at y = 1/Number of samples (expected :return: Plot with observation leverages (h)
[ "Leverage", "(", "h", ")", "per", "observation", "with", "a", "red", "line", "plotted", "at", "y", "=", "1", "/", "Number", "of", "samples", "(", "expected", ":", "return", ":", "Plot", "with", "observation", "leverages", "(", "h", ")" ]
train
https://github.com/Gscorreia89/pyChemometrics/blob/539f5cd719795685271faa7fb1c6d53d7dd4de19/pyChemometrics/PCAPlotMixin.py#L213-L225
Gscorreia89/pyChemometrics
pyChemometrics/ChemometricsScaler.py
_handle_zeros_in_scale
def _handle_zeros_in_scale(scale, copy=True): """ Makes sure that whenever scale is zero, we handle it correctly. This happens in most scalers when we have constant features. """ # if we are fitting on 1D arrays, scale might be a scalar if numpy.isscalar(scale): if scale == .0: ...
python
def _handle_zeros_in_scale(scale, copy=True): """ Makes sure that whenever scale is zero, we handle it correctly. This happens in most scalers when we have constant features. """ # if we are fitting on 1D arrays, scale might be a scalar if numpy.isscalar(scale): if scale == .0: ...
[ "def", "_handle_zeros_in_scale", "(", "scale", ",", "copy", "=", "True", ")", ":", "# if we are fitting on 1D arrays, scale might be a scalar", "if", "numpy", ".", "isscalar", "(", "scale", ")", ":", "if", "scale", "==", ".0", ":", "scale", "=", "1.", "return", ...
Makes sure that whenever scale is zero, we handle it correctly. This happens in most scalers when we have constant features.
[ "Makes", "sure", "that", "whenever", "scale", "is", "zero", "we", "handle", "it", "correctly", ".", "This", "happens", "in", "most", "scalers", "when", "we", "have", "constant", "features", "." ]
train
https://github.com/Gscorreia89/pyChemometrics/blob/539f5cd719795685271faa7fb1c6d53d7dd4de19/pyChemometrics/ChemometricsScaler.py#L216-L232
Gscorreia89/pyChemometrics
pyChemometrics/ChemometricsScaler.py
ChemometricsScaler._reset
def _reset(self): """ Reset internal data-dependent state of the scaler, if necessary. __init__ parameters are not touched. """ # Checking one attribute is enough, because they are all set together # in partial_fit if hasattr(self, 'scale_'): del sel...
python
def _reset(self): """ Reset internal data-dependent state of the scaler, if necessary. __init__ parameters are not touched. """ # Checking one attribute is enough, because they are all set together # in partial_fit if hasattr(self, 'scale_'): del sel...
[ "def", "_reset", "(", "self", ")", ":", "# Checking one attribute is enough, because they are all set together", "# in partial_fit", "if", "hasattr", "(", "self", ",", "'scale_'", ")", ":", "del", "self", ".", "scale_", "del", "self", ".", "n_samples_seen_", "del", ...
Reset internal data-dependent state of the scaler, if necessary. __init__ parameters are not touched.
[ "Reset", "internal", "data", "-", "dependent", "state", "of", "the", "scaler", "if", "necessary", ".", "__init__", "parameters", "are", "not", "touched", "." ]
train
https://github.com/Gscorreia89/pyChemometrics/blob/539f5cd719795685271faa7fb1c6d53d7dd4de19/pyChemometrics/ChemometricsScaler.py#L37-L50
Gscorreia89/pyChemometrics
pyChemometrics/ChemometricsScaler.py
ChemometricsScaler.fit
def fit(self, X, y=None): """ Compute the mean and standard deviation from a dataset to use in future scaling operations. :param X: Data matrix to scale. :type X: numpy.ndarray, shape [n_samples, n_features] :param y: Passthrough for Scikit-learn ``Pipeline`` compatibility. ...
python
def fit(self, X, y=None): """ Compute the mean and standard deviation from a dataset to use in future scaling operations. :param X: Data matrix to scale. :type X: numpy.ndarray, shape [n_samples, n_features] :param y: Passthrough for Scikit-learn ``Pipeline`` compatibility. ...
[ "def", "fit", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "# Reset internal state before fitting", "self", ".", "_reset", "(", ")", "return", "self", ".", "partial_fit", "(", "X", ",", "y", ")" ]
Compute the mean and standard deviation from a dataset to use in future scaling operations. :param X: Data matrix to scale. :type X: numpy.ndarray, shape [n_samples, n_features] :param y: Passthrough for Scikit-learn ``Pipeline`` compatibility. :type y: None :return: Fitted obje...
[ "Compute", "the", "mean", "and", "standard", "deviation", "from", "a", "dataset", "to", "use", "in", "future", "scaling", "operations", "." ]
train
https://github.com/Gscorreia89/pyChemometrics/blob/539f5cd719795685271faa7fb1c6d53d7dd4de19/pyChemometrics/ChemometricsScaler.py#L52-L66
Gscorreia89/pyChemometrics
pyChemometrics/ChemometricsScaler.py
ChemometricsScaler.partial_fit
def partial_fit(self, X, y=None): """ Performs online computation of mean and standard deviation on X for later scaling. All of X is processed as a single batch. This is intended for cases when `fit` is not feasible due to very large number of `n_samples` or because X is ...
python
def partial_fit(self, X, y=None): """ Performs online computation of mean and standard deviation on X for later scaling. All of X is processed as a single batch. This is intended for cases when `fit` is not feasible due to very large number of `n_samples` or because X is ...
[ "def", "partial_fit", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "X", "=", "check_array", "(", "X", ",", "accept_sparse", "=", "(", "'csr'", ",", "'csc'", ")", ",", "copy", "=", "self", ".", "copy", ",", "warn_on_dtype", "=", "True", ...
Performs online computation of mean and standard deviation on X for later scaling. All of X is processed as a single batch. This is intended for cases when `fit` is not feasible due to very large number of `n_samples` or because X is read from a continuous stream. The algorithm ...
[ "Performs", "online", "computation", "of", "mean", "and", "standard", "deviation", "on", "X", "for", "later", "scaling", ".", "All", "of", "X", "is", "processed", "as", "a", "single", "batch", ".", "This", "is", "intended", "for", "cases", "when", "fit", ...
train
https://github.com/Gscorreia89/pyChemometrics/blob/539f5cd719795685271faa7fb1c6d53d7dd4de19/pyChemometrics/ChemometricsScaler.py#L68-L136
Gscorreia89/pyChemometrics
pyChemometrics/ChemometricsScaler.py
ChemometricsScaler.transform
def transform(self, X, y=None, copy=None): """ Perform standardization by centering and scaling using the parameters. :param X: Data matrix to scale. :type X: numpy.ndarray, shape [n_samples, n_features] :param y: Passthrough for scikit-learn ``Pipeline`` compatibility. ...
python
def transform(self, X, y=None, copy=None): """ Perform standardization by centering and scaling using the parameters. :param X: Data matrix to scale. :type X: numpy.ndarray, shape [n_samples, n_features] :param y: Passthrough for scikit-learn ``Pipeline`` compatibility. ...
[ "def", "transform", "(", "self", ",", "X", ",", "y", "=", "None", ",", "copy", "=", "None", ")", ":", "check_is_fitted", "(", "self", ",", "'scale_'", ")", "copy", "=", "copy", "if", "copy", "is", "not", "None", "else", "self", ".", "copy", "X", ...
Perform standardization by centering and scaling using the parameters. :param X: Data matrix to scale. :type X: numpy.ndarray, shape [n_samples, n_features] :param y: Passthrough for scikit-learn ``Pipeline`` compatibility. :type y: None :param bool copy: Copy the X matrix. ...
[ "Perform", "standardization", "by", "centering", "and", "scaling", "using", "the", "parameters", "." ]
train
https://github.com/Gscorreia89/pyChemometrics/blob/539f5cd719795685271faa7fb1c6d53d7dd4de19/pyChemometrics/ChemometricsScaler.py#L138-L169
Gscorreia89/pyChemometrics
pyChemometrics/ChemometricsScaler.py
ChemometricsScaler.inverse_transform
def inverse_transform(self, X, copy=None): """ Scale back the data to the original representation. :param X: Scaled data matrix. :type X: numpy.ndarray, shape [n_samples, n_features] :param bool copy: Copy the X data matrix. :return: X data matrix with the scaling operat...
python
def inverse_transform(self, X, copy=None): """ Scale back the data to the original representation. :param X: Scaled data matrix. :type X: numpy.ndarray, shape [n_samples, n_features] :param bool copy: Copy the X data matrix. :return: X data matrix with the scaling operat...
[ "def", "inverse_transform", "(", "self", ",", "X", ",", "copy", "=", "None", ")", ":", "check_is_fitted", "(", "self", ",", "'scale_'", ")", "copy", "=", "copy", "if", "copy", "is", "not", "None", "else", "self", ".", "copy", "if", "sparse", ".", "is...
Scale back the data to the original representation. :param X: Scaled data matrix. :type X: numpy.ndarray, shape [n_samples, n_features] :param bool copy: Copy the X data matrix. :return: X data matrix with the scaling operation reverted. :rtype: numpy.ndarray, shape [n_samples, ...
[ "Scale", "back", "the", "data", "to", "the", "original", "representation", "." ]
train
https://github.com/Gscorreia89/pyChemometrics/blob/539f5cd719795685271faa7fb1c6d53d7dd4de19/pyChemometrics/ChemometricsScaler.py#L171-L205
Gscorreia89/pyChemometrics
pyChemometrics/ChemometricsPLS.py
ChemometricsPLS.leverages
def leverages(self, block='X'): """ Calculate the leverages for each observation :return: :rtype: """ # TODO check with matlab and simca try: if block == 'X': return np.dot(self.scores_t, np.dot(np.linalg.inv(np.dot(self.scores_t.T, sel...
python
def leverages(self, block='X'): """ Calculate the leverages for each observation :return: :rtype: """ # TODO check with matlab and simca try: if block == 'X': return np.dot(self.scores_t, np.dot(np.linalg.inv(np.dot(self.scores_t.T, sel...
[ "def", "leverages", "(", "self", ",", "block", "=", "'X'", ")", ":", "# TODO check with matlab and simca", "try", ":", "if", "block", "==", "'X'", ":", "return", "np", ".", "dot", "(", "self", ".", "scores_t", ",", "np", ".", "dot", "(", "np", ".", "...
Calculate the leverages for each observation :return: :rtype:
[ "Calculate", "the", "leverages", "for", "each", "observation", ":", "return", ":", ":", "rtype", ":" ]
train
https://github.com/Gscorreia89/pyChemometrics/blob/539f5cd719795685271faa7fb1c6d53d7dd4de19/pyChemometrics/ChemometricsPLS.py#L683-L698
CitrineInformatics/pypif-sdk
pypif_sdk/func/replace_funcs.py
_recurse_replace
def _recurse_replace(obj, key, new_key, sub, remove): """Recursive helper for `replace_by_key`""" if isinstance(obj, list): return [_recurse_replace(x, key, new_key, sub, remove) for x in obj] if isinstance(obj, dict): for k, v in list(obj.items()): if k == key and v in sub: ...
python
def _recurse_replace(obj, key, new_key, sub, remove): """Recursive helper for `replace_by_key`""" if isinstance(obj, list): return [_recurse_replace(x, key, new_key, sub, remove) for x in obj] if isinstance(obj, dict): for k, v in list(obj.items()): if k == key and v in sub: ...
[ "def", "_recurse_replace", "(", "obj", ",", "key", ",", "new_key", ",", "sub", ",", "remove", ")", ":", "if", "isinstance", "(", "obj", ",", "list", ")", ":", "return", "[", "_recurse_replace", "(", "x", ",", "key", ",", "new_key", ",", "sub", ",", ...
Recursive helper for `replace_by_key`
[ "Recursive", "helper", "for", "replace_by_key" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/replace_funcs.py#L6-L18
CitrineInformatics/pypif-sdk
pypif_sdk/func/replace_funcs.py
replace_by_key
def replace_by_key(pif, key, subs, new_key=None, remove=False): """Replace values that match a key Deeply traverses the pif object, looking for `key` and replacing values in accordance with `subs`. If `new_key` is set, the replaced values are assigned to that key. If `remove` is `True`, the old `...
python
def replace_by_key(pif, key, subs, new_key=None, remove=False): """Replace values that match a key Deeply traverses the pif object, looking for `key` and replacing values in accordance with `subs`. If `new_key` is set, the replaced values are assigned to that key. If `remove` is `True`, the old `...
[ "def", "replace_by_key", "(", "pif", ",", "key", ",", "subs", ",", "new_key", "=", "None", ",", "remove", "=", "False", ")", ":", "if", "not", "new_key", ":", "new_key", "=", "key", "remove", "=", "False", "orig", "=", "pif", ".", "as_dictionary", "(...
Replace values that match a key Deeply traverses the pif object, looking for `key` and replacing values in accordance with `subs`. If `new_key` is set, the replaced values are assigned to that key. If `remove` is `True`, the old `key` pairs are removed.
[ "Replace", "values", "that", "match", "a", "key" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/func/replace_funcs.py#L21-L34
CitrineInformatics/pypif-sdk
pypif_sdk/accessor.py
get_propety_by_name
def get_propety_by_name(pif, name): """Get a property by name""" warn("This method has been deprecated in favor of get_property_by_name") return next((x for x in pif.properties if x.name == name), None)
python
def get_propety_by_name(pif, name): """Get a property by name""" warn("This method has been deprecated in favor of get_property_by_name") return next((x for x in pif.properties if x.name == name), None)
[ "def", "get_propety_by_name", "(", "pif", ",", "name", ")", ":", "warn", "(", "\"This method has been deprecated in favor of get_property_by_name\"", ")", "return", "next", "(", "(", "x", "for", "x", "in", "pif", ".", "properties", "if", "x", ".", "name", "==", ...
Get a property by name
[ "Get", "a", "property", "by", "name" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/accessor.py#L3-L6
CitrineInformatics/pypif-sdk
pypif_sdk/accessor.py
get_property_by_name
def get_property_by_name(pif, name): """Get a property by name""" return next((x for x in pif.properties if x.name == name), None)
python
def get_property_by_name(pif, name): """Get a property by name""" return next((x for x in pif.properties if x.name == name), None)
[ "def", "get_property_by_name", "(", "pif", ",", "name", ")", ":", "return", "next", "(", "(", "x", "for", "x", "in", "pif", ".", "properties", "if", "x", ".", "name", "==", "name", ")", ",", "None", ")" ]
Get a property by name
[ "Get", "a", "property", "by", "name" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/accessor.py#L8-L10
CitrineInformatics/pypif-sdk
pypif_sdk/readview/core.py
new_keypair
def new_keypair(key, value, ambig, unambig): """ Check new keypair against existing unambiguous dict :param key: of pair :param value: of pair :param ambig: set of keys with ambig decoding :param unambig: set of keys with unambig decoding :return: """ if key in ambig: return...
python
def new_keypair(key, value, ambig, unambig): """ Check new keypair against existing unambiguous dict :param key: of pair :param value: of pair :param ambig: set of keys with ambig decoding :param unambig: set of keys with unambig decoding :return: """ if key in ambig: return...
[ "def", "new_keypair", "(", "key", ",", "value", ",", "ambig", ",", "unambig", ")", ":", "if", "key", "in", "ambig", ":", "return", "if", "key", "in", "unambig", "and", "value", "!=", "unambig", "[", "key", "]", ":", "ambig", ".", "add", "(", "key",...
Check new keypair against existing unambiguous dict :param key: of pair :param value: of pair :param ambig: set of keys with ambig decoding :param unambig: set of keys with unambig decoding :return:
[ "Check", "new", "keypair", "against", "existing", "unambiguous", "dict" ]
train
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/readview/core.py#L17-L36