id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
52,500
DemocracyClub/uk-election-ids
uk_election_ids/election_ids.py
IdBuilder.with_division
def with_division(self, division): """Add a division segment Args: division (str): Official name of an electoral division. Returns: IdBuilder Raises: ValueError """ if division is None: division = '' division = sl...
python
def with_division(self, division): """Add a division segment Args: division (str): Official name of an electoral division. Returns: IdBuilder Raises: ValueError """ if division is None: division = '' division = sl...
[ "def", "with_division", "(", "self", ",", "division", ")", ":", "if", "division", "is", "None", ":", "division", "=", "''", "division", "=", "slugify", "(", "division", ")", "self", ".", "_validate_division", "(", "division", ")", "self", ".", "division", ...
Add a division segment Args: division (str): Official name of an electoral division. Returns: IdBuilder Raises: ValueError
[ "Add", "a", "division", "segment" ]
566895e15b539e8a7fa3bebb680d5cd326cf6b6b
https://github.com/DemocracyClub/uk-election-ids/blob/566895e15b539e8a7fa3bebb680d5cd326cf6b6b/uk_election_ids/election_ids.py#L100-L117
52,501
Pixelapse/pyglass
pyglass/utils.py
execute
def execute(cmd): ''' Call cmd and return output. return None if any exception occurs ''' try: return safely_decode(check_output(cmd)) except Exception as e: logger.warn(u'Couldnt execute cmd: %s.\nReason: %s' % (cmd, e)) return None
python
def execute(cmd): ''' Call cmd and return output. return None if any exception occurs ''' try: return safely_decode(check_output(cmd)) except Exception as e: logger.warn(u'Couldnt execute cmd: %s.\nReason: %s' % (cmd, e)) return None
[ "def", "execute", "(", "cmd", ")", ":", "try", ":", "return", "safely_decode", "(", "check_output", "(", "cmd", ")", ")", "except", "Exception", "as", "e", ":", "logger", ".", "warn", "(", "u'Couldnt execute cmd: %s.\\nReason: %s'", "%", "(", "cmd", ",", "...
Call cmd and return output. return None if any exception occurs
[ "Call", "cmd", "and", "return", "output", ".", "return", "None", "if", "any", "exception", "occurs" ]
83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33
https://github.com/Pixelapse/pyglass/blob/83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33/pyglass/utils.py#L13-L19
52,502
dev-pipeline/dev-pipeline-core
lib/devpipeline_core/env.py
create_environment
def create_environment(component_config): """ Create a modified environment. Arguments component_config - The configuration for a component. """ ret = os.environ.copy() for env in component_config.get_list("dp.env_list"): real_env = env.upper() value = os.environ.get(real_en...
python
def create_environment(component_config): """ Create a modified environment. Arguments component_config - The configuration for a component. """ ret = os.environ.copy() for env in component_config.get_list("dp.env_list"): real_env = env.upper() value = os.environ.get(real_en...
[ "def", "create_environment", "(", "component_config", ")", ":", "ret", "=", "os", ".", "environ", ".", "copy", "(", ")", "for", "env", "in", "component_config", ".", "get_list", "(", "\"dp.env_list\"", ")", ":", "real_env", "=", "env", ".", "upper", "(", ...
Create a modified environment. Arguments component_config - The configuration for a component.
[ "Create", "a", "modified", "environment", "." ]
fa40c050a56202485070b0300bb8695e9388c34f
https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/env.py#L41-L55
52,503
sci-bots/pygtkhelpers
pygtkhelpers/ui/views/surface.py
LayerAlphaController.set_scale_alpha_from_selection
def set_scale_alpha_from_selection(self): ''' Set scale marker to alpha for selected layer. ''' # 1. Look up selected layer. selection = self.treeview_layers.get_selection() list_store, selected_iter = selection.get_selected() # 2. Set adjustment to current alph...
python
def set_scale_alpha_from_selection(self): ''' Set scale marker to alpha for selected layer. ''' # 1. Look up selected layer. selection = self.treeview_layers.get_selection() list_store, selected_iter = selection.get_selected() # 2. Set adjustment to current alph...
[ "def", "set_scale_alpha_from_selection", "(", "self", ")", ":", "# 1. Look up selected layer.", "selection", "=", "self", ".", "treeview_layers", ".", "get_selection", "(", ")", "list_store", ",", "selected_iter", "=", "selection", ".", "get_selected", "(", ")", "#...
Set scale marker to alpha for selected layer.
[ "Set", "scale", "marker", "to", "alpha", "for", "selected", "layer", "." ]
3a6e6d6340221c686229cd1c951d7537dae81b07
https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/views/surface.py#L135-L152
52,504
sci-bots/pygtkhelpers
pygtkhelpers/ui/views/surface.py
LayerAlphaController.set_alpha_for_selection
def set_alpha_for_selection(self, alpha): ''' Set alpha for selected layer. ''' # 1. Look up selected layer. selection = self.treeview_layers.get_selection() list_store, selected_iter = selection.get_selected() # 2. Set alpha value for layer (if selected). ...
python
def set_alpha_for_selection(self, alpha): ''' Set alpha for selected layer. ''' # 1. Look up selected layer. selection = self.treeview_layers.get_selection() list_store, selected_iter = selection.get_selected() # 2. Set alpha value for layer (if selected). ...
[ "def", "set_alpha_for_selection", "(", "self", ",", "alpha", ")", ":", "# 1. Look up selected layer.", "selection", "=", "self", ".", "treeview_layers", ".", "get_selection", "(", ")", "list_store", ",", "selected_iter", "=", "selection", ".", "get_selected", "(", ...
Set alpha for selected layer.
[ "Set", "alpha", "for", "selected", "layer", "." ]
3a6e6d6340221c686229cd1c951d7537dae81b07
https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/views/surface.py#L154-L170
52,505
MatiasSM/fcb
fcb/sending/SentLog.py
SentLog.process_data
def process_data(self, block): """expects Block from Compressor""" if hasattr(block, 'send_destinations') and block.send_destinations: self.fire(events.FileProcessed(block)) self._log_in_db(block) if self._sent_log_file: self._log_in_sent_log(block) ...
python
def process_data(self, block): """expects Block from Compressor""" if hasattr(block, 'send_destinations') and block.send_destinations: self.fire(events.FileProcessed(block)) self._log_in_db(block) if self._sent_log_file: self._log_in_sent_log(block) ...
[ "def", "process_data", "(", "self", ",", "block", ")", ":", "if", "hasattr", "(", "block", ",", "'send_destinations'", ")", "and", "block", ".", "send_destinations", ":", "self", ".", "fire", "(", "events", ".", "FileProcessed", "(", "block", ")", ")", "...
expects Block from Compressor
[ "expects", "Block", "from", "Compressor" ]
92a6c535287ea1c1ef986954a5d66e7905fb6221
https://github.com/MatiasSM/fcb/blob/92a6c535287ea1c1ef986954a5d66e7905fb6221/fcb/sending/SentLog.py#L19-L32
52,506
ProjetPP/PPP-Core
ppp_core/config.py
Module.should_send
def should_send(self, request): """Returns whether or not the request should be sent to the modules, based on the filters.""" if self.filters.get('whitelist', None): return request.tree.type in self.filters['whitelist'] elif self.filters.get('blacklist', None): re...
python
def should_send(self, request): """Returns whether or not the request should be sent to the modules, based on the filters.""" if self.filters.get('whitelist', None): return request.tree.type in self.filters['whitelist'] elif self.filters.get('blacklist', None): re...
[ "def", "should_send", "(", "self", ",", "request", ")", ":", "if", "self", ".", "filters", ".", "get", "(", "'whitelist'", ",", "None", ")", ":", "return", "request", ".", "tree", ".", "type", "in", "self", ".", "filters", "[", "'whitelist'", "]", "e...
Returns whether or not the request should be sent to the modules, based on the filters.
[ "Returns", "whether", "or", "not", "the", "request", "should", "be", "sent", "to", "the", "modules", "based", "on", "the", "filters", "." ]
49ee5b16325aa7134e2e423cf75e7b2609df96a0
https://github.com/ProjetPP/PPP-Core/blob/49ee5b16325aa7134e2e423cf75e7b2609df96a0/ppp_core/config.py#L28-L36
52,507
alphagov/estools
estools/command/river.py
get
def get(args): """ Get a river by name. """ m = RiverManager(args.hosts) r = m.get(args.name) if r: print(json.dumps(r, indent=2)) else: sys.exit(1)
python
def get(args): """ Get a river by name. """ m = RiverManager(args.hosts) r = m.get(args.name) if r: print(json.dumps(r, indent=2)) else: sys.exit(1)
[ "def", "get", "(", "args", ")", ":", "m", "=", "RiverManager", "(", "args", ".", "hosts", ")", "r", "=", "m", ".", "get", "(", "args", ".", "name", ")", "if", "r", ":", "print", "(", "json", ".", "dumps", "(", "r", ",", "indent", "=", "2", ...
Get a river by name.
[ "Get", "a", "river", "by", "name", "." ]
ee016ceb14cd83ee61e338fe0e226998914df97c
https://github.com/alphagov/estools/blob/ee016ceb14cd83ee61e338fe0e226998914df97c/estools/command/river.py#L57-L66
52,508
alphagov/estools
estools/command/river.py
create
def create(args): """ Create a river. This command expects to be fed a JSON document on STDIN. """ data = json.load(sys.stdin) m = RiverManager(args.hosts) m.create(args.name, data)
python
def create(args): """ Create a river. This command expects to be fed a JSON document on STDIN. """ data = json.load(sys.stdin) m = RiverManager(args.hosts) m.create(args.name, data)
[ "def", "create", "(", "args", ")", ":", "data", "=", "json", ".", "load", "(", "sys", ".", "stdin", ")", "m", "=", "RiverManager", "(", "args", ".", "hosts", ")", "m", ".", "create", "(", "args", ".", "name", ",", "data", ")" ]
Create a river. This command expects to be fed a JSON document on STDIN.
[ "Create", "a", "river", ".", "This", "command", "expects", "to", "be", "fed", "a", "JSON", "document", "on", "STDIN", "." ]
ee016ceb14cd83ee61e338fe0e226998914df97c
https://github.com/alphagov/estools/blob/ee016ceb14cd83ee61e338fe0e226998914df97c/estools/command/river.py#L70-L76
52,509
alphagov/estools
estools/command/river.py
delete
def delete(args): """ Delete a river by name """ m = RiverManager(args.hosts) m.delete(args.name)
python
def delete(args): """ Delete a river by name """ m = RiverManager(args.hosts) m.delete(args.name)
[ "def", "delete", "(", "args", ")", ":", "m", "=", "RiverManager", "(", "args", ".", "hosts", ")", "m", ".", "delete", "(", "args", ".", "name", ")" ]
Delete a river by name
[ "Delete", "a", "river", "by", "name" ]
ee016ceb14cd83ee61e338fe0e226998914df97c
https://github.com/alphagov/estools/blob/ee016ceb14cd83ee61e338fe0e226998914df97c/estools/command/river.py#L80-L85
52,510
alphagov/estools
estools/command/river.py
compare
def compare(args): """ Compare the extant river with the given name to the passed JSON. The command will exit with a return code of 0 if the named river is configured as specified, and 1 otherwise. """ data = json.load(sys.stdin) m = RiverManager(args.hosts) if m.compare(args.name, data)...
python
def compare(args): """ Compare the extant river with the given name to the passed JSON. The command will exit with a return code of 0 if the named river is configured as specified, and 1 otherwise. """ data = json.load(sys.stdin) m = RiverManager(args.hosts) if m.compare(args.name, data)...
[ "def", "compare", "(", "args", ")", ":", "data", "=", "json", ".", "load", "(", "sys", ".", "stdin", ")", "m", "=", "RiverManager", "(", "args", ".", "hosts", ")", "if", "m", ".", "compare", "(", "args", ".", "name", ",", "data", ")", ":", "sys...
Compare the extant river with the given name to the passed JSON. The command will exit with a return code of 0 if the named river is configured as specified, and 1 otherwise.
[ "Compare", "the", "extant", "river", "with", "the", "given", "name", "to", "the", "passed", "JSON", ".", "The", "command", "will", "exit", "with", "a", "return", "code", "of", "0", "if", "the", "named", "river", "is", "configured", "as", "specified", "an...
ee016ceb14cd83ee61e338fe0e226998914df97c
https://github.com/alphagov/estools/blob/ee016ceb14cd83ee61e338fe0e226998914df97c/estools/command/river.py#L89-L100
52,511
RI-imaging/qpsphere
qpsphere/imagefit/__init__.py
analyze
def analyze(qpi, model, n0, r0, c0=None, imagekw={}, ret_center=False, ret_pha_offset=False, ret_qpi=False): """Fit refractive index and radius to a phase image of a sphere Parameters ---------- qpi: QPImage Quantitative phase image information model: str Name of the lig...
python
def analyze(qpi, model, n0, r0, c0=None, imagekw={}, ret_center=False, ret_pha_offset=False, ret_qpi=False): """Fit refractive index and radius to a phase image of a sphere Parameters ---------- qpi: QPImage Quantitative phase image information model: str Name of the lig...
[ "def", "analyze", "(", "qpi", ",", "model", ",", "n0", ",", "r0", ",", "c0", "=", "None", ",", "imagekw", "=", "{", "}", ",", "ret_center", "=", "False", ",", "ret_pha_offset", "=", "False", ",", "ret_qpi", "=", "False", ")", ":", "res", "=", "ma...
Fit refractive index and radius to a phase image of a sphere Parameters ---------- qpi: QPImage Quantitative phase image information model: str Name of the light-scattering model (see :const:`qpsphere.models.available`) n0: float Approximate refractive index of the s...
[ "Fit", "refractive", "index", "and", "radius", "to", "a", "phase", "image", "of", "a", "sphere" ]
3cfa0e9fb8e81be8c820abbeccd47242e7972ac1
https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/imagefit/__init__.py#L4-L53
52,512
Pixelapse/pyglass
setup.py
rm_tempdirs
def rm_tempdirs(): ''' Remove temporary build folders ''' tempdirs = [Dir.BUILD, Dir.COCOA_BUILD, Dir.LIB] for tempdir in tempdirs: if os.path.exists(tempdir): shutil.rmtree(tempdir, ignore_errors=True)
python
def rm_tempdirs(): ''' Remove temporary build folders ''' tempdirs = [Dir.BUILD, Dir.COCOA_BUILD, Dir.LIB] for tempdir in tempdirs: if os.path.exists(tempdir): shutil.rmtree(tempdir, ignore_errors=True)
[ "def", "rm_tempdirs", "(", ")", ":", "tempdirs", "=", "[", "Dir", ".", "BUILD", ",", "Dir", ".", "COCOA_BUILD", ",", "Dir", ".", "LIB", "]", "for", "tempdir", "in", "tempdirs", ":", "if", "os", ".", "path", ".", "exists", "(", "tempdir", ")", ":", ...
Remove temporary build folders
[ "Remove", "temporary", "build", "folders" ]
83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33
https://github.com/Pixelapse/pyglass/blob/83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33/setup.py#L38-L43
52,513
bdastur/rex
rex.py
reformat_pattern
def reformat_pattern(pattern, compile=False): ''' Apply the filters on user pattern to generate a new regular expression pattern. A user provided variable, should start with an alphabet, can be alphanumeric and can have _. ''' # User pattern: (w:<name>) --> Changes to (?P<name>\w) rex_p...
python
def reformat_pattern(pattern, compile=False): ''' Apply the filters on user pattern to generate a new regular expression pattern. A user provided variable, should start with an alphabet, can be alphanumeric and can have _. ''' # User pattern: (w:<name>) --> Changes to (?P<name>\w) rex_p...
[ "def", "reformat_pattern", "(", "pattern", ",", "compile", "=", "False", ")", ":", "# User pattern: (w:<name>) --> Changes to (?P<name>\\w)", "rex_pattern", "=", "re", ".", "sub", "(", "r'\\(w:<([\\w\\d_]+)>\\)'", ",", "'(?P<\\\\1>\\w+)'", ",", "pattern", ")", "# User ...
Apply the filters on user pattern to generate a new regular expression pattern. A user provided variable, should start with an alphabet, can be alphanumeric and can have _.
[ "Apply", "the", "filters", "on", "user", "pattern", "to", "generate", "a", "new", "regular", "expression", "pattern", ".", "A", "user", "provided", "variable", "should", "start", "with", "an", "alphabet", "can", "be", "alphanumeric", "and", "can", "have", "_...
e45173aa93f05a1d2ee65746e6f6cc6d829daf60
https://github.com/bdastur/rex/blob/e45173aa93f05a1d2ee65746e6f6cc6d829daf60/rex.py#L61-L199
52,514
bdastur/rex
rex.py
match_string
def match_string(pattern, search_string): ''' Match a pattern in a string ''' rexobj = REX(pattern, None) rexpatstr = reformat_pattern(pattern) #print "rexpatstr: ", rexpatstr rexpat = re.compile(rexpatstr) rexobj.rex_patternstr = rexpatstr rexobj.rex_pattern = rexpat line_co...
python
def match_string(pattern, search_string): ''' Match a pattern in a string ''' rexobj = REX(pattern, None) rexpatstr = reformat_pattern(pattern) #print "rexpatstr: ", rexpatstr rexpat = re.compile(rexpatstr) rexobj.rex_patternstr = rexpatstr rexobj.rex_pattern = rexpat line_co...
[ "def", "match_string", "(", "pattern", ",", "search_string", ")", ":", "rexobj", "=", "REX", "(", "pattern", ",", "None", ")", "rexpatstr", "=", "reformat_pattern", "(", "pattern", ")", "#print \"rexpatstr: \", rexpatstr", "rexpat", "=", "re", ".", "compile", ...
Match a pattern in a string
[ "Match", "a", "pattern", "in", "a", "string" ]
e45173aa93f05a1d2ee65746e6f6cc6d829daf60
https://github.com/bdastur/rex/blob/e45173aa93f05a1d2ee65746e6f6cc6d829daf60/rex.py#L202-L224
52,515
bdastur/rex
rex.py
populate_resobj
def populate_resobj(rexobj, mobj, loc): ''' Popuate the result object and append it to the rexobj results. ''' resobj = REXResult(mobj, loc) rexobj.matches.append(resobj) rexobj.res_count += 1
python
def populate_resobj(rexobj, mobj, loc): ''' Popuate the result object and append it to the rexobj results. ''' resobj = REXResult(mobj, loc) rexobj.matches.append(resobj) rexobj.res_count += 1
[ "def", "populate_resobj", "(", "rexobj", ",", "mobj", ",", "loc", ")", ":", "resobj", "=", "REXResult", "(", "mobj", ",", "loc", ")", "rexobj", ".", "matches", ".", "append", "(", "resobj", ")", "rexobj", ".", "res_count", "+=", "1" ]
Popuate the result object and append it to the rexobj results.
[ "Popuate", "the", "result", "object", "and", "append", "it", "to", "the", "rexobj", "results", "." ]
e45173aa93f05a1d2ee65746e6f6cc6d829daf60
https://github.com/bdastur/rex/blob/e45173aa93f05a1d2ee65746e6f6cc6d829daf60/rex.py#L227-L234
52,516
bdastur/rex
rex.py
match_file
def match_file(pattern, filename): ''' The function will match a pattern in a file and return a rex object, which will have all the matches found in the file. ''' # Validate user data. if pattern is None: return None if os.stat(filename).st_size == 0: return None rexo...
python
def match_file(pattern, filename): ''' The function will match a pattern in a file and return a rex object, which will have all the matches found in the file. ''' # Validate user data. if pattern is None: return None if os.stat(filename).st_size == 0: return None rexo...
[ "def", "match_file", "(", "pattern", ",", "filename", ")", ":", "# Validate user data.", "if", "pattern", "is", "None", ":", "return", "None", "if", "os", ".", "stat", "(", "filename", ")", ".", "st_size", "==", "0", ":", "return", "None", "rexobj", "=",...
The function will match a pattern in a file and return a rex object, which will have all the matches found in the file.
[ "The", "function", "will", "match", "a", "pattern", "in", "a", "file", "and", "return", "a", "rex", "object", "which", "will", "have", "all", "the", "matches", "found", "in", "the", "file", "." ]
e45173aa93f05a1d2ee65746e6f6cc6d829daf60
https://github.com/bdastur/rex/blob/e45173aa93f05a1d2ee65746e6f6cc6d829daf60/rex.py#L237-L272
52,517
bdastur/rex
rex.py
parse_tabular_string
def parse_tabular_string(search_string, header_keys, delimiter=None, merge_list=None): ''' Given a string in a tabular format, parse it and return a dictionary @args: search_string: This is a string in tabular format (e.g...
python
def parse_tabular_string(search_string, header_keys, delimiter=None, merge_list=None): ''' Given a string in a tabular format, parse it and return a dictionary @args: search_string: This is a string in tabular format (e.g...
[ "def", "parse_tabular_string", "(", "search_string", ",", "header_keys", ",", "delimiter", "=", "None", ",", "merge_list", "=", "None", ")", ":", "first_line", "=", "True", "parsed_results", "=", "[", "]", "for", "line", "in", "search_string", ".", "splitlines...
Given a string in a tabular format, parse it and return a dictionary @args: search_string: This is a string in tabular format (e.g.: output of df command) header_keys: This is a list of strings for the headers. delimiter(optional): Default is None, which translates to spaces ...
[ "Given", "a", "string", "in", "a", "tabular", "format", "parse", "it", "and", "return", "a", "dictionary" ]
e45173aa93f05a1d2ee65746e6f6cc6d829daf60
https://github.com/bdastur/rex/blob/e45173aa93f05a1d2ee65746e6f6cc6d829daf60/rex.py#L338-L380
52,518
bdastur/rex
rex.py
dump_rexobj_results
def dump_rexobj_results(rexobj, options=None): ''' print all the results. ''' print("-" * 60) print("Match count: ", rexobj.res_count) matches = rexobj.matches for match in matches: print("Loc:", match.loc, ":: ") for key in match.named_groups.keys(): print("%s: %...
python
def dump_rexobj_results(rexobj, options=None): ''' print all the results. ''' print("-" * 60) print("Match count: ", rexobj.res_count) matches = rexobj.matches for match in matches: print("Loc:", match.loc, ":: ") for key in match.named_groups.keys(): print("%s: %...
[ "def", "dump_rexobj_results", "(", "rexobj", ",", "options", "=", "None", ")", ":", "print", "(", "\"-\"", "*", "60", ")", "print", "(", "\"Match count: \"", ",", "rexobj", ".", "res_count", ")", "matches", "=", "rexobj", ".", "matches", "for", "match", ...
print all the results.
[ "print", "all", "the", "results", "." ]
e45173aa93f05a1d2ee65746e6f6cc6d829daf60
https://github.com/bdastur/rex/blob/e45173aa93f05a1d2ee65746e6f6cc6d829daf60/rex.py#L383-L395
52,519
bdastur/rex
rex.py
get_match_value
def get_match_value(rexobj, key, index=0): ''' Return a matched value for the key for a specific match from the results. ''' if rexobj is None: return None if rexobj.res_count == 0: return None try: return rexobj.matches[index].named_groups[key] except IndexErro...
python
def get_match_value(rexobj, key, index=0): ''' Return a matched value for the key for a specific match from the results. ''' if rexobj is None: return None if rexobj.res_count == 0: return None try: return rexobj.matches[index].named_groups[key] except IndexErro...
[ "def", "get_match_value", "(", "rexobj", ",", "key", ",", "index", "=", "0", ")", ":", "if", "rexobj", "is", "None", ":", "return", "None", "if", "rexobj", ".", "res_count", "==", "0", ":", "return", "None", "try", ":", "return", "rexobj", ".", "matc...
Return a matched value for the key for a specific match from the results.
[ "Return", "a", "matched", "value", "for", "the", "key", "for", "a", "specific", "match", "from", "the", "results", "." ]
e45173aa93f05a1d2ee65746e6f6cc6d829daf60
https://github.com/bdastur/rex/blob/e45173aa93f05a1d2ee65746e6f6cc6d829daf60/rex.py#L408-L424
52,520
the01/paps-settings
app/restAPI.py
save_resource
def save_resource(plugin_name, resource_name, resource_data): """ Save a resource in local cache :param plugin_name: Name of plugin this resource belongs to :type plugin_name: str :param resource_name: Name of resource :type resource_name: str :param resource_data: Resource content - base64...
python
def save_resource(plugin_name, resource_name, resource_data): """ Save a resource in local cache :param plugin_name: Name of plugin this resource belongs to :type plugin_name: str :param resource_name: Name of resource :type resource_name: str :param resource_data: Resource content - base64...
[ "def", "save_resource", "(", "plugin_name", ",", "resource_name", ",", "resource_data", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "resource_dir_path", ",", "plugin_name", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ...
Save a resource in local cache :param plugin_name: Name of plugin this resource belongs to :type plugin_name: str :param resource_name: Name of resource :type resource_name: str :param resource_data: Resource content - base64 encoded :type resource_data: str :rtype: None
[ "Save", "a", "resource", "in", "local", "cache" ]
48fb65eb0fa7929a0bb381c6dad28d0197b44c83
https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/app/restAPI.py#L33-L51
52,521
mogproject/mog-commons-python
src/mog_commons/command.py
__convert_env
def __convert_env(env, encoding): """Environment variables should be bytes not unicode on Windows.""" d = dict(os.environ, **(oget(env, {}))) # workaround for Windows+Python3 environment if not SHOULD_NOT_ENCODE_ARGS: return dict((k.encode(encoding), v.encode(encoding)) for k, v in d.items()) ...
python
def __convert_env(env, encoding): """Environment variables should be bytes not unicode on Windows.""" d = dict(os.environ, **(oget(env, {}))) # workaround for Windows+Python3 environment if not SHOULD_NOT_ENCODE_ARGS: return dict((k.encode(encoding), v.encode(encoding)) for k, v in d.items()) ...
[ "def", "__convert_env", "(", "env", ",", "encoding", ")", ":", "d", "=", "dict", "(", "os", ".", "environ", ",", "*", "*", "(", "oget", "(", "env", ",", "{", "}", ")", ")", ")", "# workaround for Windows+Python3 environment", "if", "not", "SHOULD_NOT_ENC...
Environment variables should be bytes not unicode on Windows.
[ "Environment", "variables", "should", "be", "bytes", "not", "unicode", "on", "Windows", "." ]
951cf0fa9a56248b4d45be720be25f1d4b7e1bff
https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/command.py#L41-L49
52,522
XiaochenCui/cxc-gis
cxc_gis/models.py
Polyline.length
def length(self): """ Calculate total length of the polyline :return: total length in meters :rtype: float """ total_length = 0 for location_a, location_b in zip( self.locations[:-1], self.locations[1:]): total_length += Line(location_...
python
def length(self): """ Calculate total length of the polyline :return: total length in meters :rtype: float """ total_length = 0 for location_a, location_b in zip( self.locations[:-1], self.locations[1:]): total_length += Line(location_...
[ "def", "length", "(", "self", ")", ":", "total_length", "=", "0", "for", "location_a", ",", "location_b", "in", "zip", "(", "self", ".", "locations", "[", ":", "-", "1", "]", ",", "self", ".", "locations", "[", "1", ":", "]", ")", ":", "total_lengt...
Calculate total length of the polyline :return: total length in meters :rtype: float
[ "Calculate", "total", "length", "of", "the", "polyline" ]
6186e0cbe61f1b037afa39839b6da2e0519c9cf8
https://github.com/XiaochenCui/cxc-gis/blob/6186e0cbe61f1b037afa39839b6da2e0519c9cf8/cxc_gis/models.py#L110-L121
52,523
sci-bots/pygtkhelpers
pygtkhelpers/debug/dialogs.py
install_hook
def install_hook(dialog=SimpleExceptionDialog, invoke_old_hook=False, **extra): """ install the configured exception hook wrapping the old exception hook don't use it twice :oparam dialog: a different exception dialog class :oparam invoke_old_hook: should we invoke the old exception hook? """ ...
python
def install_hook(dialog=SimpleExceptionDialog, invoke_old_hook=False, **extra): """ install the configured exception hook wrapping the old exception hook don't use it twice :oparam dialog: a different exception dialog class :oparam invoke_old_hook: should we invoke the old exception hook? """ ...
[ "def", "install_hook", "(", "dialog", "=", "SimpleExceptionDialog", ",", "invoke_old_hook", "=", "False", ",", "*", "*", "extra", ")", ":", "global", "_old_hook", "assert", "_old_hook", "is", "None", "def", "new_hook", "(", "etype", ",", "eval", ",", "trace"...
install the configured exception hook wrapping the old exception hook don't use it twice :oparam dialog: a different exception dialog class :oparam invoke_old_hook: should we invoke the old exception hook?
[ "install", "the", "configured", "exception", "hook", "wrapping", "the", "old", "exception", "hook" ]
3a6e6d6340221c686229cd1c951d7537dae81b07
https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/debug/dialogs.py#L98-L116
52,524
kobejohn/PQHelper
pqhelper/versus.py
Advisor._summarize_action
def _summarize_action(self, root_action): """Return a dictionary with various information about this root_action. Note: Scoring assumes that each actor makes the "best" choices in their turn based on the simulation available. """ def is_target_node(node): ret...
python
def _summarize_action(self, root_action): """Return a dictionary with various information about this root_action. Note: Scoring assumes that each actor makes the "best" choices in their turn based on the simulation available. """ def is_target_node(node): ret...
[ "def", "_summarize_action", "(", "self", ",", "root_action", ")", ":", "def", "is_target_node", "(", "node", ")", ":", "return", "isinstance", "(", "node", ",", "base", ".", "EOT", ")", "or", "(", "node", "is", "root_action", ")", "# store per-turn results f...
Return a dictionary with various information about this root_action. Note: Scoring assumes that each actor makes the "best" choices in their turn based on the simulation available.
[ "Return", "a", "dictionary", "with", "various", "information", "about", "this", "root_action", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/versus.py#L39-L88
52,525
kobejohn/PQHelper
pqhelper/versus.py
Advisor._relative_score
def _relative_score(self, start_eot, end_eot, active, passive): """Return the balance of perception between the two nodes. A positive score indicates the result is relatively better for active. """ active_start = self._score_eot_for_actor(start_eot, active) passive_start = self._...
python
def _relative_score(self, start_eot, end_eot, active, passive): """Return the balance of perception between the two nodes. A positive score indicates the result is relatively better for active. """ active_start = self._score_eot_for_actor(start_eot, active) passive_start = self._...
[ "def", "_relative_score", "(", "self", ",", "start_eot", ",", "end_eot", ",", "active", ",", "passive", ")", ":", "active_start", "=", "self", ".", "_score_eot_for_actor", "(", "start_eot", ",", "active", ")", "passive_start", "=", "self", ".", "_score_eot_for...
Return the balance of perception between the two nodes. A positive score indicates the result is relatively better for active.
[ "Return", "the", "balance", "of", "perception", "between", "the", "two", "nodes", ".", "A", "positive", "score", "indicates", "the", "result", "is", "relatively", "better", "for", "active", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/versus.py#L90-L98
52,526
kobejohn/PQHelper
pqhelper/versus.py
Advisor._score_eot_for_actor
def _score_eot_for_actor(self, eot, actor): """Have the actor evaluate the end of turn for itself only.""" # currently just simple sum of own attributes # could be much more sophisticated in both analysis (e.g. formulas) # and breadth of items analyzed (e.g. require other actor, the boar...
python
def _score_eot_for_actor(self, eot, actor): """Have the actor evaluate the end of turn for itself only.""" # currently just simple sum of own attributes # could be much more sophisticated in both analysis (e.g. formulas) # and breadth of items analyzed (e.g. require other actor, the boar...
[ "def", "_score_eot_for_actor", "(", "self", ",", "eot", ",", "actor", ")", ":", "# currently just simple sum of own attributes", "# could be much more sophisticated in both analysis (e.g. formulas)", "# and breadth of items analyzed (e.g. require other actor, the board)", "end_state", "=...
Have the actor evaluate the end of turn for itself only.
[ "Have", "the", "actor", "evaluate", "the", "end", "of", "turn", "for", "itself", "only", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/versus.py#L100-L112
52,527
kobejohn/PQHelper
pqhelper/versus.py
Advisor._summarize_result
def _summarize_result(self, root_action, leaf_eot): """Return a dict with useful information that summarizes this action.""" root_board = root_action.parent.board action_detail = root_action.position_pair score = self._relative_score(root_action, leaf_eot, ...
python
def _summarize_result(self, root_action, leaf_eot): """Return a dict with useful information that summarizes this action.""" root_board = root_action.parent.board action_detail = root_action.position_pair score = self._relative_score(root_action, leaf_eot, ...
[ "def", "_summarize_result", "(", "self", ",", "root_action", ",", "leaf_eot", ")", ":", "root_board", "=", "root_action", ".", "parent", ".", "board", "action_detail", "=", "root_action", ".", "position_pair", "score", "=", "self", ".", "_relative_score", "(", ...
Return a dict with useful information that summarizes this action.
[ "Return", "a", "dict", "with", "useful", "information", "that", "summarizes", "this", "action", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/versus.py#L114-L130
52,528
RI-imaging/qpsphere
qpsphere/imagefit/alg.py
export_phase_error_hdf5
def export_phase_error_hdf5(h5path, identifier, index, phase, mphase, model, n0, r0, spi_params): """Export the phase error to an hdf5 file Parameters ---------- h5path: str or pathlib.Path path to hdf5 output file identifier: str unique identifier of the...
python
def export_phase_error_hdf5(h5path, identifier, index, phase, mphase, model, n0, r0, spi_params): """Export the phase error to an hdf5 file Parameters ---------- h5path: str or pathlib.Path path to hdf5 output file identifier: str unique identifier of the...
[ "def", "export_phase_error_hdf5", "(", "h5path", ",", "identifier", ",", "index", ",", "phase", ",", "mphase", ",", "model", ",", "n0", ",", "r0", ",", "spi_params", ")", ":", "with", "h5py", ".", "File", "(", "h5path", ",", "mode", "=", "\"a\"", ")", ...
Export the phase error to an hdf5 file Parameters ---------- h5path: str or pathlib.Path path to hdf5 output file identifier: str unique identifier of the input phase (e.g. `qpimage.QPImage["identifier"]`) index: int iteration index phase: 2d real-valued np.ndarr...
[ "Export", "the", "phase", "error", "to", "an", "hdf5", "file" ]
3cfa0e9fb8e81be8c820abbeccd47242e7972ac1
https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/imagefit/alg.py#L350-L390
52,529
tundish/turberfield-dialogue
turberfield/dialogue/model.py
SceneScript.scripts
def scripts(cls, pkg, metadata, paths=[], **kwargs): """This class method is the preferred way to create SceneScript objects. :param str pkg: The dotted name of the package containing the scripts. :param metadata: A mapping or data object. This parameter permits searching among scri...
python
def scripts(cls, pkg, metadata, paths=[], **kwargs): """This class method is the preferred way to create SceneScript objects. :param str pkg: The dotted name of the package containing the scripts. :param metadata: A mapping or data object. This parameter permits searching among scri...
[ "def", "scripts", "(", "cls", ",", "pkg", ",", "metadata", ",", "paths", "=", "[", "]", ",", "*", "*", "kwargs", ")", ":", "for", "path", "in", "paths", ":", "try", ":", "fP", "=", "pkg_resources", ".", "resource_filename", "(", "pkg", ",", "path",...
This class method is the preferred way to create SceneScript objects. :param str pkg: The dotted name of the package containing the scripts. :param metadata: A mapping or data object. This parameter permits searching among scripts against particular criteria. Its use is application specific...
[ "This", "class", "method", "is", "the", "preferred", "way", "to", "create", "SceneScript", "objects", "." ]
e7ccf7c19ae162e2f315ddf2642394e858529b4a
https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/model.py#L271-L301
52,530
tundish/turberfield-dialogue
turberfield/dialogue/model.py
SceneScript.read
def read(text, name=None): """Read a block of text as a docutils document. :param str text: Scene script text. :param str name: An optional name for the document. :return: A document object. """ doc = docutils.utils.new_document(name, SceneScript.settings) parse...
python
def read(text, name=None): """Read a block of text as a docutils document. :param str text: Scene script text. :param str name: An optional name for the document. :return: A document object. """ doc = docutils.utils.new_document(name, SceneScript.settings) parse...
[ "def", "read", "(", "text", ",", "name", "=", "None", ")", ":", "doc", "=", "docutils", ".", "utils", ".", "new_document", "(", "name", ",", "SceneScript", ".", "settings", ")", "parser", "=", "docutils", ".", "parsers", ".", "rst", ".", "Parser", "(...
Read a block of text as a docutils document. :param str text: Scene script text. :param str name: An optional name for the document. :return: A document object.
[ "Read", "a", "block", "of", "text", "as", "a", "docutils", "document", "." ]
e7ccf7c19ae162e2f315ddf2642394e858529b4a
https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/model.py#L305-L316
52,531
tundish/turberfield-dialogue
turberfield/dialogue/model.py
SceneScript.select
def select(self, personae, relative=False, roles=1): """Select a persona for each entity declared in the scene. :param personae: A sequence of Personae. :param bool relative: Affects imports from namespace packages. Used for testing only. :param int roles: The maximum number...
python
def select(self, personae, relative=False, roles=1): """Select a persona for each entity declared in the scene. :param personae: A sequence of Personae. :param bool relative: Affects imports from namespace packages. Used for testing only. :param int roles: The maximum number...
[ "def", "select", "(", "self", ",", "personae", ",", "relative", "=", "False", ",", "roles", "=", "1", ")", ":", "def", "constrained", "(", "entity", ")", ":", "return", "(", "len", "(", "entity", "[", "\"options\"", "]", ".", "get", "(", "\"types\"",...
Select a persona for each entity declared in the scene. :param personae: A sequence of Personae. :param bool relative: Affects imports from namespace packages. Used for testing only. :param int roles: The maximum number of roles allocated to each persona. :return: An Ordered...
[ "Select", "a", "persona", "for", "each", "entity", "declared", "in", "the", "scene", "." ]
e7ccf7c19ae162e2f315ddf2642394e858529b4a
https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/model.py#L331-L393
52,532
tundish/turberfield-dialogue
turberfield/dialogue/model.py
SceneScript.cast
def cast(self, mapping): """Allocate the scene script a cast of personae for each of its entities. :param mapping: A dictionary of {Entity, Persona} :return: The SceneScript object. """ # See 'citation' method in # http://docutils.sourceforge.net/docutils/parsers/rst/st...
python
def cast(self, mapping): """Allocate the scene script a cast of personae for each of its entities. :param mapping: A dictionary of {Entity, Persona} :return: The SceneScript object. """ # See 'citation' method in # http://docutils.sourceforge.net/docutils/parsers/rst/st...
[ "def", "cast", "(", "self", ",", "mapping", ")", ":", "# See 'citation' method in", "# http://docutils.sourceforge.net/docutils/parsers/rst/states.py", "for", "c", ",", "p", "in", "mapping", ".", "items", "(", ")", ":", "self", ".", "doc", ".", "note_citation", "(...
Allocate the scene script a cast of personae for each of its entities. :param mapping: A dictionary of {Entity, Persona} :return: The SceneScript object.
[ "Allocate", "the", "scene", "script", "a", "cast", "of", "personae", "for", "each", "of", "its", "entities", "." ]
e7ccf7c19ae162e2f315ddf2642394e858529b4a
https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/model.py#L395-L411
52,533
tundish/turberfield-dialogue
turberfield/dialogue/model.py
SceneScript.run
def run(self): """Parse the script file. :rtype: :py:class:`~turberfield.dialogue.model.Model` """ model = Model(self.fP, self.doc) self.doc.walkabout(model) return model
python
def run(self): """Parse the script file. :rtype: :py:class:`~turberfield.dialogue.model.Model` """ model = Model(self.fP, self.doc) self.doc.walkabout(model) return model
[ "def", "run", "(", "self", ")", ":", "model", "=", "Model", "(", "self", ".", "fP", ",", "self", ".", "doc", ")", "self", ".", "doc", ".", "walkabout", "(", "model", ")", "return", "model" ]
Parse the script file. :rtype: :py:class:`~turberfield.dialogue.model.Model`
[ "Parse", "the", "script", "file", "." ]
e7ccf7c19ae162e2f315ddf2642394e858529b4a
https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/model.py#L413-L420
52,534
kbknapp/Clapp-py
examples/main.py
my_main
def my_main(context): """ The starting point for your app.""" print('starting MyApp...') if context['debug']: print('Context:') for k in context: print('Key: {}\nValue: {}'.format(k, context[k])) print('Done!') return 0
python
def my_main(context): """ The starting point for your app.""" print('starting MyApp...') if context['debug']: print('Context:') for k in context: print('Key: {}\nValue: {}'.format(k, context[k])) print('Done!') return 0
[ "def", "my_main", "(", "context", ")", ":", "print", "(", "'starting MyApp...'", ")", "if", "context", "[", "'debug'", "]", ":", "print", "(", "'Context:'", ")", "for", "k", "in", "context", ":", "print", "(", "'Key: {}\\nValue: {}'", ".", "format", "(", ...
The starting point for your app.
[ "The", "starting", "point", "for", "your", "app", "." ]
7afc8904a4e49e33066f6582cee4f334a4140c59
https://github.com/kbknapp/Clapp-py/blob/7afc8904a4e49e33066f6582cee4f334a4140c59/examples/main.py#L16-L24
52,535
kobejohn/PQHelper
pqhelper/easy.py
versus_summaries
def versus_summaries(turns=2, sims_to_average=2, async_results_q=None): """Return summaries of the likely resutls of each available action.. Arguments: - turns: how many turns to simulate. - in 2013, 1 is fast (seconds), 2 is slow (seconds), 3 who knows - sims_to_average: how many times to run ...
python
def versus_summaries(turns=2, sims_to_average=2, async_results_q=None): """Return summaries of the likely resutls of each available action.. Arguments: - turns: how many turns to simulate. - in 2013, 1 is fast (seconds), 2 is slow (seconds), 3 who knows - sims_to_average: how many times to run ...
[ "def", "versus_summaries", "(", "turns", "=", "2", ",", "sims_to_average", "=", "2", ",", "async_results_q", "=", "None", ")", ":", "board", ",", "player", ",", "opponent", ",", "extra_actions", "=", "_state_investigator", ".", "get_versus", "(", ")", "if", ...
Return summaries of the likely resutls of each available action.. Arguments: - turns: how many turns to simulate. - in 2013, 1 is fast (seconds), 2 is slow (seconds), 3 who knows - sims_to_average: how many times to run the simulation to get more representative average results of each actio...
[ "Return", "summaries", "of", "the", "likely", "resutls", "of", "each", "available", "action", ".." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/easy.py#L8-L56
52,536
dcaune/perseus-lib-python-common
majormode/perseus/utils/file_util.py
build_tree_pathname
def build_tree_pathname(filename, directory_depth=8, pathname_separator_character=os.sep): """ Return a pathname built of the specified number of sub-directories, and where each directory is named after the nth letter of the filename corresponding to the directory depth. Examples:: >>> build...
python
def build_tree_pathname(filename, directory_depth=8, pathname_separator_character=os.sep): """ Return a pathname built of the specified number of sub-directories, and where each directory is named after the nth letter of the filename corresponding to the directory depth. Examples:: >>> build...
[ "def", "build_tree_pathname", "(", "filename", ",", "directory_depth", "=", "8", ",", "pathname_separator_character", "=", "os", ".", "sep", ")", ":", "pathname", "=", "''", "(", "filename_without_extension", ",", "_file_extension_", ")", "=", "os", ".", "path",...
Return a pathname built of the specified number of sub-directories, and where each directory is named after the nth letter of the filename corresponding to the directory depth. Examples:: >>> build_tree_pathname('foo.txt', 2, '/') 'f/o/' >>> build_tree_pathname('0123456789abcdef') ...
[ "Return", "a", "pathname", "built", "of", "the", "specified", "number", "of", "sub", "-", "directories", "and", "where", "each", "directory", "is", "named", "after", "the", "nth", "letter", "of", "the", "filename", "corresponding", "to", "the", "directory", ...
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/file_util.py#L34-L64
52,537
dcaune/perseus-lib-python-common
majormode/perseus/utils/file_util.py
build_tree_file_pathname
def build_tree_file_pathname(filename, directory_depth=8, pathname_separator_character=os.sep): """ Return a file pathname which pathname is built of the specified number of sub-directories, and where each directory is named after the nth letter of the filename corresponding to the directory depth. ...
python
def build_tree_file_pathname(filename, directory_depth=8, pathname_separator_character=os.sep): """ Return a file pathname which pathname is built of the specified number of sub-directories, and where each directory is named after the nth letter of the filename corresponding to the directory depth. ...
[ "def", "build_tree_file_pathname", "(", "filename", ",", "directory_depth", "=", "8", ",", "pathname_separator_character", "=", "os", ".", "sep", ")", ":", "return", "build_tree_pathname", "(", "filename", ",", "directory_depth", ",", "pathname_separator_character", "...
Return a file pathname which pathname is built of the specified number of sub-directories, and where each directory is named after the nth letter of the filename corresponding to the directory depth. Examples:: >>> build_tree_file_pathname('foo.txt', 2, '/') 'f/o/foo.txt' >>> build...
[ "Return", "a", "file", "pathname", "which", "pathname", "is", "built", "of", "the", "specified", "number", "of", "sub", "-", "directories", "and", "where", "each", "directory", "is", "named", "after", "the", "nth", "letter", "of", "the", "filename", "corresp...
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/file_util.py#L67-L91
52,538
dcaune/perseus-lib-python-common
majormode/perseus/utils/file_util.py
find_root_path
def find_root_path(absolute_path, relative_path): """ Return the root path of a path relative to an absolute path. Example: @param absolute_path: an absolute path that is ended by the specified relative path. @param relative_path: a relative path that ends the specified absolute p...
python
def find_root_path(absolute_path, relative_path): """ Return the root path of a path relative to an absolute path. Example: @param absolute_path: an absolute path that is ended by the specified relative path. @param relative_path: a relative path that ends the specified absolute p...
[ "def", "find_root_path", "(", "absolute_path", ",", "relative_path", ")", ":", "_absolute_path", "=", "os", ".", "path", ".", "normpath", "(", "absolute_path", ")", "_relative_path", "=", "os", ".", "path", ".", "normpath", "(", "relative_path", ")", "index", ...
Return the root path of a path relative to an absolute path. Example: @param absolute_path: an absolute path that is ended by the specified relative path. @param relative_path: a relative path that ends the specified absolute path. @return: the root path of the relative path.
[ "Return", "the", "root", "path", "of", "a", "path", "relative", "to", "an", "absolute", "path", "." ]
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/file_util.py#L94-L115
52,539
dcaune/perseus-lib-python-common
majormode/perseus/utils/file_util.py
get_file_checksum
def get_file_checksum(file_path_name, hash_algorithm_name='md5'): """ Generate the MD5 checksum of the specified file. @param file_path_name: the absolute path and name of the file to generate its MD5 checksum. @param hash_algorithm_name: specify the hash algorithm to use. Refer ...
python
def get_file_checksum(file_path_name, hash_algorithm_name='md5'): """ Generate the MD5 checksum of the specified file. @param file_path_name: the absolute path and name of the file to generate its MD5 checksum. @param hash_algorithm_name: specify the hash algorithm to use. Refer ...
[ "def", "get_file_checksum", "(", "file_path_name", ",", "hash_algorithm_name", "=", "'md5'", ")", ":", "hash_algorithm", "=", "hashlib", ".", "new", "(", "hash_algorithm_name", ")", "if", "sys", ".", "platform", "==", "\"win32\"", ":", "import", "ctypes", "secto...
Generate the MD5 checksum of the specified file. @param file_path_name: the absolute path and name of the file to generate its MD5 checksum. @param hash_algorithm_name: specify the hash algorithm to use. Refer to ``hashlib.algorithms`` to get the names of the hash algorithms guarante...
[ "Generate", "the", "MD5", "checksum", "of", "the", "specified", "file", "." ]
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/file_util.py#L118-L172
52,540
dcaune/perseus-lib-python-common
majormode/perseus/utils/file_util.py
make_directory_if_not_exists
def make_directory_if_not_exists(path): """ Create the specified path, making all intermediate-level directories needed to contain the leaf directory. Ignore any error that would occur if the leaf directory already exists. @note: all the intermediate-level directories are created with the ...
python
def make_directory_if_not_exists(path): """ Create the specified path, making all intermediate-level directories needed to contain the leaf directory. Ignore any error that would occur if the leaf directory already exists. @note: all the intermediate-level directories are created with the ...
[ "def", "make_directory_if_not_exists", "(", "path", ")", ":", "try", ":", "os", ".", "makedirs", "(", "path", ")", "except", "OSError", ",", "error", ":", "# Ignore if the directory has been already created.", "if", "error", ".", "errno", "<>", "errno", ".", "EE...
Create the specified path, making all intermediate-level directories needed to contain the leaf directory. Ignore any error that would occur if the leaf directory already exists. @note: all the intermediate-level directories are created with the default mode is 0777 (octal). @param path: the ...
[ "Create", "the", "specified", "path", "making", "all", "intermediate", "-", "level", "directories", "needed", "to", "contain", "the", "leaf", "directory", ".", "Ignore", "any", "error", "that", "would", "occur", "if", "the", "leaf", "directory", "already", "ex...
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/file_util.py#L175-L193
52,541
dcaune/perseus-lib-python-common
majormode/perseus/utils/file_util.py
move_file
def move_file(source_file_pathname, destination_file_pathname): """ Move the the specified file to another location. If the destination already exists, it is replaced silently. This function is an alternative to ``shutil.move(src, dst)``, which might raise ``OSError`` if the destination already ex...
python
def move_file(source_file_pathname, destination_file_pathname): """ Move the the specified file to another location. If the destination already exists, it is replaced silently. This function is an alternative to ``shutil.move(src, dst)``, which might raise ``OSError`` if the destination already ex...
[ "def", "move_file", "(", "source_file_pathname", ",", "destination_file_pathname", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "destination_file_pathname", ")", ":", "os", ".", "remove", "(", "destination_file_pathname", ")", "shutil", ".", "move", "(...
Move the the specified file to another location. If the destination already exists, it is replaced silently. This function is an alternative to ``shutil.move(src, dst)``, which might raise ``OSError`` if the destination already exists. @param source_file_pathname: the complete path and name of the fi...
[ "Move", "the", "the", "specified", "file", "to", "another", "location", ".", "If", "the", "destination", "already", "exists", "it", "is", "replaced", "silently", "." ]
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/file_util.py#L196-L213
52,542
dcaune/perseus-lib-python-common
majormode/perseus/utils/file_util.py
which
def which(exe_name): """ Locate a program file in the user's path. @param exec_name: name of the executable file. @return: ``None`` if the executable has not been found in the user's path, or the path for the executable file. """ def is_exe(file_path_name): return os.path.isfil...
python
def which(exe_name): """ Locate a program file in the user's path. @param exec_name: name of the executable file. @return: ``None`` if the executable has not been found in the user's path, or the path for the executable file. """ def is_exe(file_path_name): return os.path.isfil...
[ "def", "which", "(", "exe_name", ")", ":", "def", "is_exe", "(", "file_path_name", ")", ":", "return", "os", ".", "path", ".", "isfile", "(", "file_path_name", ")", "and", "os", ".", "access", "(", "file_path_name", ",", "os", ".", "X_OK", ")", "is_pla...
Locate a program file in the user's path. @param exec_name: name of the executable file. @return: ``None`` if the executable has not been found in the user's path, or the path for the executable file.
[ "Locate", "a", "program", "file", "in", "the", "user", "s", "path", "." ]
ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496
https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/file_util.py#L266-L299
52,543
FreekKalter/geoselect
geoselect.py
get_time
def get_time(filename, tags): """ Get most reliable timestamp from a picture, running down a couple of options. Filename, exif tags, modification time. """ # use exif 'Image DateTime' field as the time if 'Image DateTime' in tags.keys(): return time.strptime(str(tags['Image DateTi...
python
def get_time(filename, tags): """ Get most reliable timestamp from a picture, running down a couple of options. Filename, exif tags, modification time. """ # use exif 'Image DateTime' field as the time if 'Image DateTime' in tags.keys(): return time.strptime(str(tags['Image DateTi...
[ "def", "get_time", "(", "filename", ",", "tags", ")", ":", "# use exif 'Image DateTime' field as the time\r", "if", "'Image DateTime'", "in", "tags", ".", "keys", "(", ")", ":", "return", "time", ".", "strptime", "(", "str", "(", "tags", "[", "'Image DateTime'",...
Get most reliable timestamp from a picture, running down a couple of options. Filename, exif tags, modification time.
[ "Get", "most", "reliable", "timestamp", "from", "a", "picture", "running", "down", "a", "couple", "of", "options", ".", "Filename", "exif", "tags", "modification", "time", "." ]
2c6ab869d50215eba21dce3e1770bcf8ecdb41f3
https://github.com/FreekKalter/geoselect/blob/2c6ab869d50215eba21dce3e1770bcf8ecdb41f3/geoselect.py#L44-L60
52,544
FreekKalter/geoselect
geoselect.py
location_filter
def location_filter(files_with_tags, location, radius): ''' Get photos taken within the specified radius from a given point. ''' on_location = dict() for f, tags in files_with_tags.items(): if 'GPS GPSLatitude' in tags: try: lat = convert_to_decimal(str(ta...
python
def location_filter(files_with_tags, location, radius): ''' Get photos taken within the specified radius from a given point. ''' on_location = dict() for f, tags in files_with_tags.items(): if 'GPS GPSLatitude' in tags: try: lat = convert_to_decimal(str(ta...
[ "def", "location_filter", "(", "files_with_tags", ",", "location", ",", "radius", ")", ":", "on_location", "=", "dict", "(", ")", "for", "f", ",", "tags", "in", "files_with_tags", ".", "items", "(", ")", ":", "if", "'GPS GPSLatitude'", "in", "tags", ":", ...
Get photos taken within the specified radius from a given point.
[ "Get", "photos", "taken", "within", "the", "specified", "radius", "from", "a", "given", "point", "." ]
2c6ab869d50215eba21dce3e1770bcf8ecdb41f3
https://github.com/FreekKalter/geoselect/blob/2c6ab869d50215eba21dce3e1770bcf8ecdb41f3/geoselect.py#L113-L130
52,545
FreekKalter/geoselect
geoselect.py
add_based_on_time
def add_based_on_time(files_with_tags, on_location): ''' Sometimes the first photo in a series does not have gps coordinates because the phone doesnt have a gps-fix yet. To add these photos as well we take the list of photos wich where taken in the right location. Then add any photos taken whitin 10...
python
def add_based_on_time(files_with_tags, on_location): ''' Sometimes the first photo in a series does not have gps coordinates because the phone doesnt have a gps-fix yet. To add these photos as well we take the list of photos wich where taken in the right location. Then add any photos taken whitin 10...
[ "def", "add_based_on_time", "(", "files_with_tags", ",", "on_location", ")", ":", "to_add", "=", "dict", "(", ")", "for", "veiling_f", ",", "veiling_tags", "in", "on_location", ".", "items", "(", ")", ":", "for", "compare_f", ",", "compare_tags", "in", "file...
Sometimes the first photo in a series does not have gps coordinates because the phone doesnt have a gps-fix yet. To add these photos as well we take the list of photos wich where taken in the right location. Then add any photos taken whitin 10 minutes of these photos, because they are almost certainly ta...
[ "Sometimes", "the", "first", "photo", "in", "a", "series", "does", "not", "have", "gps", "coordinates", "because", "the", "phone", "doesnt", "have", "a", "gps", "-", "fix", "yet", ".", "To", "add", "these", "photos", "as", "well", "we", "take", "the", ...
2c6ab869d50215eba21dce3e1770bcf8ecdb41f3
https://github.com/FreekKalter/geoselect/blob/2c6ab869d50215eba21dce3e1770bcf8ecdb41f3/geoselect.py#L133-L146
52,546
klmitch/requiem
requiem/client.py
RESTClient._debug
def _debug(self, msg, *args, **kwargs): """Emit debugging messages.""" # Do nothing if debugging is disabled if self._debug_stream is None or self._debug_stream is False: return # What are we passing to the format? if kwargs: fmtargs = kwargs els...
python
def _debug(self, msg, *args, **kwargs): """Emit debugging messages.""" # Do nothing if debugging is disabled if self._debug_stream is None or self._debug_stream is False: return # What are we passing to the format? if kwargs: fmtargs = kwargs els...
[ "def", "_debug", "(", "self", ",", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Do nothing if debugging is disabled", "if", "self", ".", "_debug_stream", "is", "None", "or", "self", ".", "_debug_stream", "is", "False", ":", "return", "# W...
Emit debugging messages.
[ "Emit", "debugging", "messages", "." ]
0b3b5252e1b3487af732a8666b3bdc2e7035fef5
https://github.com/klmitch/requiem/blob/0b3b5252e1b3487af732a8666b3bdc2e7035fef5/requiem/client.py#L68-L82
52,547
klmitch/requiem
requiem/client.py
RESTClient._make_req
def _make_req(self, method, url, methname, headers=None): """Create a request object for the specified method and url.""" # Build up headers hset = hdrs.HeaderDict() # Walk through our global headers for hdr, value in self._headers.items(): # If it's a callable, cal...
python
def _make_req(self, method, url, methname, headers=None): """Create a request object for the specified method and url.""" # Build up headers hset = hdrs.HeaderDict() # Walk through our global headers for hdr, value in self._headers.items(): # If it's a callable, cal...
[ "def", "_make_req", "(", "self", ",", "method", ",", "url", ",", "methname", ",", "headers", "=", "None", ")", ":", "# Build up headers", "hset", "=", "hdrs", ".", "HeaderDict", "(", ")", "# Walk through our global headers", "for", "hdr", ",", "value", "in",...
Create a request object for the specified method and url.
[ "Create", "a", "request", "object", "for", "the", "specified", "method", "and", "url", "." ]
0b3b5252e1b3487af732a8666b3bdc2e7035fef5
https://github.com/klmitch/requiem/blob/0b3b5252e1b3487af732a8666b3bdc2e7035fef5/requiem/client.py#L110-L139
52,548
dev-pipeline/dev-pipeline-core
lib/devpipeline_core/plugin.py
query_plugins
def query_plugins(entry_point_name): """ Find everything with a specific entry_point. Results will be returned as a dictionary, with the name as the key and the entry_point itself as the value. Arguments: entry_point_name - the name of the entry_point to populate """ entries = {} f...
python
def query_plugins(entry_point_name): """ Find everything with a specific entry_point. Results will be returned as a dictionary, with the name as the key and the entry_point itself as the value. Arguments: entry_point_name - the name of the entry_point to populate """ entries = {} f...
[ "def", "query_plugins", "(", "entry_point_name", ")", ":", "entries", "=", "{", "}", "for", "entry_point", "in", "pkg_resources", ".", "iter_entry_points", "(", "entry_point_name", ")", ":", "entries", "[", "entry_point", ".", "name", "]", "=", "entry_point", ...
Find everything with a specific entry_point. Results will be returned as a dictionary, with the name as the key and the entry_point itself as the value. Arguments: entry_point_name - the name of the entry_point to populate
[ "Find", "everything", "with", "a", "specific", "entry_point", ".", "Results", "will", "be", "returned", "as", "a", "dictionary", "with", "the", "name", "as", "the", "key", "and", "the", "entry_point", "itself", "as", "the", "value", "." ]
fa40c050a56202485070b0300bb8695e9388c34f
https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/plugin.py#L10-L22
52,549
decryptus/sonicprobe
sonicprobe/libs/xys.py
prefixedDec
def prefixedDec(nstr, schema): """ !~~prefixedDec corresponding strings in documents must begin with the associated string in the schema, and the right part of strings in documents must be decimal. """ if not nstr.startswith(schema): return False postfix = nstr[len(sc...
python
def prefixedDec(nstr, schema): """ !~~prefixedDec corresponding strings in documents must begin with the associated string in the schema, and the right part of strings in documents must be decimal. """ if not nstr.startswith(schema): return False postfix = nstr[len(sc...
[ "def", "prefixedDec", "(", "nstr", ",", "schema", ")", ":", "if", "not", "nstr", ".", "startswith", "(", "schema", ")", ":", "return", "False", "postfix", "=", "nstr", "[", "len", "(", "schema", ")", ":", "]", "try", ":", "int", "(", "postfix", ")"...
!~~prefixedDec corresponding strings in documents must begin with the associated string in the schema, and the right part of strings in documents must be decimal.
[ "!~~prefixedDec", "corresponding", "strings", "in", "documents", "must", "begin", "with", "the", "associated", "string", "in", "the", "schema", "and", "the", "right", "part", "of", "strings", "in", "documents", "must", "be", "decimal", "." ]
72f73f3a40d2982d79ad68686e36aa31d94b76f8
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/xys.py#L432-L446
52,550
decryptus/sonicprobe
sonicprobe/libs/xys.py
_transschema
def _transschema(x): """ Transform a schema, once loaded from its YAML representation, to its final internal representation """ if isinstance(x, tuple): return x.__class__(_transschema(x[0]), *x[1:]) elif isinstance(x, dict): return dict((_qualify_map(key, _transschema(val)) for ...
python
def _transschema(x): """ Transform a schema, once loaded from its YAML representation, to its final internal representation """ if isinstance(x, tuple): return x.__class__(_transschema(x[0]), *x[1:]) elif isinstance(x, dict): return dict((_qualify_map(key, _transschema(val)) for ...
[ "def", "_transschema", "(", "x", ")", ":", "if", "isinstance", "(", "x", ",", "tuple", ")", ":", "return", "x", ".", "__class__", "(", "_transschema", "(", "x", "[", "0", "]", ")", ",", "*", "x", "[", "1", ":", "]", ")", "elif", "isinstance", "...
Transform a schema, once loaded from its YAML representation, to its final internal representation
[ "Transform", "a", "schema", "once", "loaded", "from", "its", "YAML", "representation", "to", "its", "final", "internal", "representation" ]
72f73f3a40d2982d79ad68686e36aa31d94b76f8
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/xys.py#L618-L630
52,551
Met48/raf
raf/__init__.py
RAFArchive._fill_entries
def _fill_entries(self): """Populate entries dictionaries from index.""" for file in self.index.files: path = self.index.paths[file.pathIndex] data_offset = file.dataOffset data_size = file.dataSize obj = RAFEntry(self._data_handle, path, data_offset, data...
python
def _fill_entries(self): """Populate entries dictionaries from index.""" for file in self.index.files: path = self.index.paths[file.pathIndex] data_offset = file.dataOffset data_size = file.dataSize obj = RAFEntry(self._data_handle, path, data_offset, data...
[ "def", "_fill_entries", "(", "self", ")", ":", "for", "file", "in", "self", ".", "index", ".", "files", ":", "path", "=", "self", ".", "index", ".", "paths", "[", "file", ".", "pathIndex", "]", "data_offset", "=", "file", ".", "dataOffset", "data_size"...
Populate entries dictionaries from index.
[ "Populate", "entries", "dictionaries", "from", "index", "." ]
cd5d19f705f22ac87e2fd3fc800c66960e987078
https://github.com/Met48/raf/blob/cd5d19f705f22ac87e2fd3fc800c66960e987078/raf/__init__.py#L60-L74
52,552
Met48/raf
raf/__init__.py
RAFMaster.find
def find(self, path=None, name=None): """ Returns most recent version of the matching file. If there are multiple files of the same name and version, a random one is used. """ if path is None and name is None: # TODO: Correct error type raise ValueError("...
python
def find(self, path=None, name=None): """ Returns most recent version of the matching file. If there are multiple files of the same name and version, a random one is used. """ if path is None and name is None: # TODO: Correct error type raise ValueError("...
[ "def", "find", "(", "self", ",", "path", "=", "None", ",", "name", "=", "None", ")", ":", "if", "path", "is", "None", "and", "name", "is", "None", ":", "# TODO: Correct error type", "raise", "ValueError", "(", "\"Path or name is required.\"", ")", "# Entries...
Returns most recent version of the matching file. If there are multiple files of the same name and version, a random one is used.
[ "Returns", "most", "recent", "version", "of", "the", "matching", "file", ".", "If", "there", "are", "multiple", "files", "of", "the", "same", "name", "and", "version", "a", "random", "one", "is", "used", "." ]
cd5d19f705f22ac87e2fd3fc800c66960e987078
https://github.com/Met48/raf/blob/cd5d19f705f22ac87e2fd3fc800c66960e987078/raf/__init__.py#L150-L164
52,553
Met48/raf
raf/__init__.py
RAFMaster.find_re
def find_re(self, pattern): """Find the most recent versions of all entries whose path matches a given pattern.""" # TODO: Reduce redundancy with RAFArchive pattern = re.compile(pattern, re.I) for k, v in six.iteritems(self.entries_full): if pattern.search(k): ...
python
def find_re(self, pattern): """Find the most recent versions of all entries whose path matches a given pattern.""" # TODO: Reduce redundancy with RAFArchive pattern = re.compile(pattern, re.I) for k, v in six.iteritems(self.entries_full): if pattern.search(k): ...
[ "def", "find_re", "(", "self", ",", "pattern", ")", ":", "# TODO: Reduce redundancy with RAFArchive", "pattern", "=", "re", ".", "compile", "(", "pattern", ",", "re", ".", "I", ")", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "self", ".", ...
Find the most recent versions of all entries whose path matches a given pattern.
[ "Find", "the", "most", "recent", "versions", "of", "all", "entries", "whose", "path", "matches", "a", "given", "pattern", "." ]
cd5d19f705f22ac87e2fd3fc800c66960e987078
https://github.com/Met48/raf/blob/cd5d19f705f22ac87e2fd3fc800c66960e987078/raf/__init__.py#L166-L173
52,554
bbengfort/commis
commis/color.py
colorize
def colorize(string, color, *args, **kwargs): """ Implements string formatting along with color specified in colorama.Fore """ string = string.format(*args, **kwargs) return color + string + colorama.Fore.RESET
python
def colorize(string, color, *args, **kwargs): """ Implements string formatting along with color specified in colorama.Fore """ string = string.format(*args, **kwargs) return color + string + colorama.Fore.RESET
[ "def", "colorize", "(", "string", ",", "color", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "string", "=", "string", ".", "format", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "color", "+", "string", "+", "colorama", ".", "...
Implements string formatting along with color specified in colorama.Fore
[ "Implements", "string", "formatting", "along", "with", "color", "specified", "in", "colorama", ".", "Fore" ]
cea696ccd1fec9c22974ae396b7e66c4275240ad
https://github.com/bbengfort/commis/blob/cea696ccd1fec9c22974ae396b7e66c4275240ad/commis/color.py#L52-L57
52,555
zengbin93/zb
zb/tools/file.py
legitimize
def legitimize(text): """Converts a string to a valid filename. """ import platform os_ = platform.system() # POSIX systems text = text.translate({ 0: None, ord('/'): '-', ord('|'): '-', }) if os_ == 'Windows': # Windows (non-POSIX namespace) text...
python
def legitimize(text): """Converts a string to a valid filename. """ import platform os_ = platform.system() # POSIX systems text = text.translate({ 0: None, ord('/'): '-', ord('|'): '-', }) if os_ == 'Windows': # Windows (non-POSIX namespace) text...
[ "def", "legitimize", "(", "text", ")", ":", "import", "platform", "os_", "=", "platform", ".", "system", "(", ")", "# POSIX systems", "text", "=", "text", ".", "translate", "(", "{", "0", ":", "None", ",", "ord", "(", "'/'", ")", ":", "'-'", ",", "...
Converts a string to a valid filename.
[ "Converts", "a", "string", "to", "a", "valid", "filename", "." ]
ccdb384a0b5801b459933220efcb71972c2b89a7
https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/tools/file.py#L11-L52
52,556
impact27/registrator
registrator/channel.py
channel_width
def channel_width(im, chanangle=None, *, chanapproxangle=None, isccsedge=False): """Get an estimation of the channel width. Parameters: ----------- im: 2d array The channel image chanangle: number, optional The angle of the channel (None if unknown) chanapproxa...
python
def channel_width(im, chanangle=None, *, chanapproxangle=None, isccsedge=False): """Get an estimation of the channel width. Parameters: ----------- im: 2d array The channel image chanangle: number, optional The angle of the channel (None if unknown) chanapproxa...
[ "def", "channel_width", "(", "im", ",", "chanangle", "=", "None", ",", "*", ",", "chanapproxangle", "=", "None", ",", "isccsedge", "=", "False", ")", ":", "# check input is numpy array", "im", "=", "np", ".", "asarray", "(", "im", ")", "# Compute the dft if ...
Get an estimation of the channel width. Parameters: ----------- im: 2d array The channel image chanangle: number, optional The angle of the channel (None if unknown) chanapproxangle: number, optional If chanangle is None, the approximate channel angle isccsedge: boolean,...
[ "Get", "an", "estimation", "of", "the", "channel", "width", "." ]
04c099d83e0466207dc5b2e40d9b03db020d4dad
https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/channel.py#L35-L143
52,557
impact27/registrator
registrator/channel.py
channel_angle
def channel_angle(im, chanapproxangle=None, *, isshiftdftedge=False, truesize=None): """Extract the channel angle from the rfft Parameters: ----------- im: 2d array The channel image chanapproxangle: number, optional If not None, an approximation of the result ...
python
def channel_angle(im, chanapproxangle=None, *, isshiftdftedge=False, truesize=None): """Extract the channel angle from the rfft Parameters: ----------- im: 2d array The channel image chanapproxangle: number, optional If not None, an approximation of the result ...
[ "def", "channel_angle", "(", "im", ",", "chanapproxangle", "=", "None", ",", "*", ",", "isshiftdftedge", "=", "False", ",", "truesize", "=", "None", ")", ":", "im", "=", "np", ".", "asarray", "(", "im", ")", "# Compute edge", "if", "not", "isshiftdftedge...
Extract the channel angle from the rfft Parameters: ----------- im: 2d array The channel image chanapproxangle: number, optional If not None, an approximation of the result isshiftdftedge: boolean, default False If The image has already been treated: (edge, dft, ffts...
[ "Extract", "the", "channel", "angle", "from", "the", "rfft" ]
04c099d83e0466207dc5b2e40d9b03db020d4dad
https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/channel.py#L146-L175
52,558
impact27/registrator
registrator/channel.py
register_channel
def register_channel(im0, im1, scale=None, ch0angle=None, chanapproxangle=None): """Register the images assuming they are channels Parameters: ----------- im0: 2d array The first image im1: 2d array The second image scale: number, optional The scale ...
python
def register_channel(im0, im1, scale=None, ch0angle=None, chanapproxangle=None): """Register the images assuming they are channels Parameters: ----------- im0: 2d array The first image im1: 2d array The second image scale: number, optional The scale ...
[ "def", "register_channel", "(", "im0", ",", "im1", ",", "scale", "=", "None", ",", "ch0angle", "=", "None", ",", "chanapproxangle", "=", "None", ")", ":", "im0", "=", "np", ".", "asarray", "(", "im0", ")", "im1", "=", "np", ".", "asarray", "(", "im...
Register the images assuming they are channels Parameters: ----------- im0: 2d array The first image im1: 2d array The second image scale: number, optional The scale difference if known ch0angle: number, optional The angle of the channel in the first image if kno...
[ "Register", "the", "images", "assuming", "they", "are", "channels" ]
04c099d83e0466207dc5b2e40d9b03db020d4dad
https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/channel.py#L230-L288
52,559
impact27/registrator
registrator/channel.py
uint8sc
def uint8sc(im): """Scale the image to uint8 Parameters: ----------- im: 2d array The image Returns: -------- im: 2d array (dtype uint8) The scaled image to uint8 """ im = np.asarray(im) immin = im.min() immax = im.max() imrange = immax - immin retur...
python
def uint8sc(im): """Scale the image to uint8 Parameters: ----------- im: 2d array The image Returns: -------- im: 2d array (dtype uint8) The scaled image to uint8 """ im = np.asarray(im) immin = im.min() immax = im.max() imrange = immax - immin retur...
[ "def", "uint8sc", "(", "im", ")", ":", "im", "=", "np", ".", "asarray", "(", "im", ")", "immin", "=", "im", ".", "min", "(", ")", "immax", "=", "im", ".", "max", "(", ")", "imrange", "=", "immax", "-", "immin", "return", "cv2", ".", "convertSca...
Scale the image to uint8 Parameters: ----------- im: 2d array The image Returns: -------- im: 2d array (dtype uint8) The scaled image to uint8
[ "Scale", "the", "image", "to", "uint8" ]
04c099d83e0466207dc5b2e40d9b03db020d4dad
https://github.com/impact27/registrator/blob/04c099d83e0466207dc5b2e40d9b03db020d4dad/registrator/channel.py#L291-L308
52,560
bbengfort/commis
example/example.py
GreetingCommand.handle
def handle(self, args): """ Greet each person by name. """ salutation = { 'french': 'Bonjour', 'spanish': 'Hola', 'english': 'Hello', }[args.lang.lower()] output = [] for name in args.name: output.append("{} {}!".fo...
python
def handle(self, args): """ Greet each person by name. """ salutation = { 'french': 'Bonjour', 'spanish': 'Hola', 'english': 'Hello', }[args.lang.lower()] output = [] for name in args.name: output.append("{} {}!".fo...
[ "def", "handle", "(", "self", ",", "args", ")", ":", "salutation", "=", "{", "'french'", ":", "'Bonjour'", ",", "'spanish'", ":", "'Hola'", ",", "'english'", ":", "'Hello'", ",", "}", "[", "args", ".", "lang", ".", "lower", "(", ")", "]", "output", ...
Greet each person by name.
[ "Greet", "each", "person", "by", "name", "." ]
cea696ccd1fec9c22974ae396b7e66c4275240ad
https://github.com/bbengfort/commis/blob/cea696ccd1fec9c22974ae396b7e66c4275240ad/example/example.py#L53-L66
52,561
kobejohn/PQHelper
pqhelper/capture.py
capture
def capture(board): """Try to solve the board described by board_string. Return sequence of summaries that describe how to get to the solution. """ game = Game() v = (0, 0) stub_actor = base.Actor('capture', v, v, v, v, v, v, v, v, v) root = base.State(board, stub_actor, stub_actor, ...
python
def capture(board): """Try to solve the board described by board_string. Return sequence of summaries that describe how to get to the solution. """ game = Game() v = (0, 0) stub_actor = base.Actor('capture', v, v, v, v, v, v, v, v, v) root = base.State(board, stub_actor, stub_actor, ...
[ "def", "capture", "(", "board", ")", ":", "game", "=", "Game", "(", ")", "v", "=", "(", "0", ",", "0", ")", "stub_actor", "=", "base", ".", "Actor", "(", "'capture'", ",", "v", ",", "v", ",", "v", ",", "v", ",", "v", ",", "v", ",", "v", "...
Try to solve the board described by board_string. Return sequence of summaries that describe how to get to the solution.
[ "Try", "to", "solve", "the", "board", "described", "by", "board_string", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/capture.py#L4-L34
52,562
kobejohn/PQHelper
pqhelper/capture.py
Game._disallow_state
def _disallow_state(self, state): """Disallow states that are not useful to continue simulating.""" disallow_methods = (self._is_duplicate_board, self._is_impossible_by_count) for disallow_method in disallow_methods: if disallow_method(state): ...
python
def _disallow_state(self, state): """Disallow states that are not useful to continue simulating.""" disallow_methods = (self._is_duplicate_board, self._is_impossible_by_count) for disallow_method in disallow_methods: if disallow_method(state): ...
[ "def", "_disallow_state", "(", "self", ",", "state", ")", ":", "disallow_methods", "=", "(", "self", ".", "_is_duplicate_board", ",", "self", ".", "_is_impossible_by_count", ")", "for", "disallow_method", "in", "disallow_methods", ":", "if", "disallow_method", "("...
Disallow states that are not useful to continue simulating.
[ "Disallow", "states", "that", "are", "not", "useful", "to", "continue", "simulating", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/capture.py#L43-L50
52,563
kobejohn/PQHelper
pqhelper/capture.py
Game._is_impossible_by_count
def _is_impossible_by_count(self, state): """Disallow any board that has insufficient tile count to solve.""" # count all the tile types and name them for readability counts = {tile_type: 0 for tile_type in base.Tile._all_types} standard_wildcard_type = '2' for p, tile in state.b...
python
def _is_impossible_by_count(self, state): """Disallow any board that has insufficient tile count to solve.""" # count all the tile types and name them for readability counts = {tile_type: 0 for tile_type in base.Tile._all_types} standard_wildcard_type = '2' for p, tile in state.b...
[ "def", "_is_impossible_by_count", "(", "self", ",", "state", ")", ":", "# count all the tile types and name them for readability", "counts", "=", "{", "tile_type", ":", "0", "for", "tile_type", "in", "base", ".", "Tile", ".", "_all_types", "}", "standard_wildcard_type...
Disallow any board that has insufficient tile count to solve.
[ "Disallow", "any", "board", "that", "has", "insufficient", "tile", "count", "to", "solve", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/capture.py#L56-L91
52,564
kobejohn/PQHelper
pqhelper/capture.py
_DuplicateTree.find_or_graft
def find_or_graft(self, board): """Build a tree with each level corresponding to a fixed position on board. A path of tiles is stored for each board. If any two boards have the same path, then they are the same board. If there is any difference, a new branch will be created to store that...
python
def find_or_graft(self, board): """Build a tree with each level corresponding to a fixed position on board. A path of tiles is stored for each board. If any two boards have the same path, then they are the same board. If there is any difference, a new branch will be created to store that...
[ "def", "find_or_graft", "(", "self", ",", "board", ")", ":", "is_duplicate_board", "=", "True", "# assume same until find a difference", "# compare each position", "node", "=", "self", "for", "p", ",", "new_tile", "in", "board", ".", "positions_with_tile", "(", ")",...
Build a tree with each level corresponding to a fixed position on board. A path of tiles is stored for each board. If any two boards have the same path, then they are the same board. If there is any difference, a new branch will be created to store that path. Return: True if board alrea...
[ "Build", "a", "tree", "with", "each", "level", "corresponding", "to", "a", "fixed", "position", "on", "board", ".", "A", "path", "of", "tiles", "is", "stored", "for", "each", "board", ".", "If", "any", "two", "boards", "have", "the", "same", "path", "t...
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/capture.py#L99-L127
52,565
kobejohn/PQHelper
pqhelper/base.py
StateInvestigator.get_capture
def get_capture(self): """Return the capture board or None if can't find it.""" # game game_image = self._game_image_from_screen('capture') if game_image is None: return # board board = self._board_from_game_image(game_image) if board is None: ...
python
def get_capture(self): """Return the capture board or None if can't find it.""" # game game_image = self._game_image_from_screen('capture') if game_image is None: return # board board = self._board_from_game_image(game_image) if board is None: ...
[ "def", "get_capture", "(", "self", ")", ":", "# game", "game_image", "=", "self", ".", "_game_image_from_screen", "(", "'capture'", ")", "if", "game_image", "is", "None", ":", "return", "# board", "board", "=", "self", ".", "_board_from_game_image", "(", "game...
Return the capture board or None if can't find it.
[ "Return", "the", "capture", "board", "or", "None", "if", "can", "t", "find", "it", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L107-L119
52,566
kobejohn/PQHelper
pqhelper/base.py
StateInvestigator.get_versus
def get_versus(self): """Return the versus board, player, opponent and extra actions. Return None for any parts that can't be found. """ # game game_image = self._game_image_from_screen('versus') if game_image is None: return None, None, None, None # nothing ...
python
def get_versus(self): """Return the versus board, player, opponent and extra actions. Return None for any parts that can't be found. """ # game game_image = self._game_image_from_screen('versus') if game_image is None: return None, None, None, None # nothing ...
[ "def", "get_versus", "(", "self", ")", ":", "# game", "game_image", "=", "self", ".", "_game_image_from_screen", "(", "'versus'", ")", "if", "game_image", "is", "None", ":", "return", "None", ",", "None", ",", "None", ",", "None", "# nothing else will work", ...
Return the versus board, player, opponent and extra actions. Return None for any parts that can't be found.
[ "Return", "the", "versus", "board", "player", "opponent", "and", "extra", "actions", ".", "Return", "None", "for", "any", "parts", "that", "can", "t", "be", "found", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L121-L141
52,567
kobejohn/PQHelper
pqhelper/base.py
StateInvestigator._game_image_from_screen
def _game_image_from_screen(self, game_type): """Return the image of the given game type from the screen. Return None if no game is found. """ # screen screen_img = self._screen_shot() # game image game_rect = self._game_finders[game_type].locate_in(screen_img) ...
python
def _game_image_from_screen(self, game_type): """Return the image of the given game type from the screen. Return None if no game is found. """ # screen screen_img = self._screen_shot() # game image game_rect = self._game_finders[game_type].locate_in(screen_img) ...
[ "def", "_game_image_from_screen", "(", "self", ",", "game_type", ")", ":", "# screen", "screen_img", "=", "self", ".", "_screen_shot", "(", ")", "# game image", "game_rect", "=", "self", ".", "_game_finders", "[", "game_type", "]", ".", "locate_in", "(", "scre...
Return the image of the given game type from the screen. Return None if no game is found.
[ "Return", "the", "image", "of", "the", "given", "game", "type", "from", "the", "screen", ".", "Return", "None", "if", "no", "game", "is", "found", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L146-L158
52,568
kobejohn/PQHelper
pqhelper/base.py
StateInvestigator._board_from_game_image
def _board_from_game_image(self, game_image): """Return a board object matching the board in the game image. Return None if any tiles are not identified. """ # board image board_rect = self._board_tools['board_region'].region_in(game_image) t, l, b, r = board_rect ...
python
def _board_from_game_image(self, game_image): """Return a board object matching the board in the game image. Return None if any tiles are not identified. """ # board image board_rect = self._board_tools['board_region'].region_in(game_image) t, l, b, r = board_rect ...
[ "def", "_board_from_game_image", "(", "self", ",", "game_image", ")", ":", "# board image", "board_rect", "=", "self", ".", "_board_tools", "[", "'board_region'", "]", ".", "region_in", "(", "game_image", ")", "t", ",", "l", ",", "b", ",", "r", "=", "board...
Return a board object matching the board in the game image. Return None if any tiles are not identified.
[ "Return", "a", "board", "object", "matching", "the", "board", "in", "the", "game", "image", ".", "Return", "None", "if", "any", "tiles", "are", "not", "identified", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L160-L179
52,569
kobejohn/PQHelper
pqhelper/base.py
StateInvestigator._actor_from_game_image
def _actor_from_game_image(self, name, game_image): """Return an actor object matching the one in the game image. Note: Health and mana are based on measured percentage of a fixed maximum rather than the actual maximum in the game. Arguments: name: must be 'player' or '...
python
def _actor_from_game_image(self, name, game_image): """Return an actor object matching the one in the game image. Note: Health and mana are based on measured percentage of a fixed maximum rather than the actual maximum in the game. Arguments: name: must be 'player' or '...
[ "def", "_actor_from_game_image", "(", "self", ",", "name", ",", "game_image", ")", ":", "HEALTH_MAX", "=", "100", "MANA_MAX", "=", "40", "# get the set of tools for investigating this actor", "tools", "=", "{", "'player'", ":", "self", ".", "_player_tools", ",", "...
Return an actor object matching the one in the game image. Note: Health and mana are based on measured percentage of a fixed maximum rather than the actual maximum in the game. Arguments: name: must be 'player' or 'opponent' game_image: opencv image of the main game are...
[ "Return", "an", "actor", "object", "matching", "the", "one", "in", "the", "game", "image", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L181-L226
52,570
kobejohn/PQHelper
pqhelper/base.py
StateInvestigator._count_extra_actions
def _count_extra_actions(self, game_image): """Count the number of extra actions for player in this turn.""" proportional = self._bonus_tools['extra_action_region'] # Use ProportionalRegion to isolate the extra actions area t, l, b, r = proportional.region_in(game_image) token_re...
python
def _count_extra_actions(self, game_image): """Count the number of extra actions for player in this turn.""" proportional = self._bonus_tools['extra_action_region'] # Use ProportionalRegion to isolate the extra actions area t, l, b, r = proportional.region_in(game_image) token_re...
[ "def", "_count_extra_actions", "(", "self", ",", "game_image", ")", ":", "proportional", "=", "self", ".", "_bonus_tools", "[", "'extra_action_region'", "]", "# Use ProportionalRegion to isolate the extra actions area", "t", ",", "l", ",", "b", ",", "r", "=", "propo...
Count the number of extra actions for player in this turn.
[ "Count", "the", "number", "of", "extra", "actions", "for", "player", "in", "this", "turn", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L228-L246
52,571
kobejohn/PQHelper
pqhelper/base.py
Game.ends_of_one_state
def ends_of_one_state(self, root=None, root_eot=None): """Simulate a complete turn from one state only and generate each end of turn reached in the simulation. Arguments: Exactly one of: root: a start state with no parent or root_eot: an EOT or ManaDr...
python
def ends_of_one_state(self, root=None, root_eot=None): """Simulate a complete turn from one state only and generate each end of turn reached in the simulation. Arguments: Exactly one of: root: a start state with no parent or root_eot: an EOT or ManaDr...
[ "def", "ends_of_one_state", "(", "self", ",", "root", "=", "None", ",", "root_eot", "=", "None", ")", ":", "# basic confirmation of valid arguments", "self", ".", "_argument_gauntlet", "(", "root_eot", ",", "root", ")", "# setup the starting state", "if", "root", ...
Simulate a complete turn from one state only and generate each end of turn reached in the simulation. Arguments: Exactly one of: root: a start state with no parent or root_eot: an EOT or ManaDrain transition in the simulation
[ "Simulate", "a", "complete", "turn", "from", "one", "state", "only", "and", "generate", "each", "end", "of", "turn", "reached", "in", "the", "simulation", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L271-L323
52,572
kobejohn/PQHelper
pqhelper/base.py
Game.ends_of_next_whole_turn
def ends_of_next_whole_turn(self, root): """Simulate one complete turn to completion and generate each end of turn reached during the simulation. Note on mana drain: Generates but does not continue simulation of mana drains. Arguments: root: a start state with no parent...
python
def ends_of_next_whole_turn(self, root): """Simulate one complete turn to completion and generate each end of turn reached during the simulation. Note on mana drain: Generates but does not continue simulation of mana drains. Arguments: root: a start state with no parent...
[ "def", "ends_of_next_whole_turn", "(", "self", ",", "root", ")", ":", "# simple confirmation that the root is actually a root.", "# otherwise it may seem to work but would be totally out of spec", "if", "root", ".", "parent", ":", "raise", "ValueError", "(", "'Unexpectedly receiv...
Simulate one complete turn to completion and generate each end of turn reached during the simulation. Note on mana drain: Generates but does not continue simulation of mana drains. Arguments: root: a start state with no parent
[ "Simulate", "one", "complete", "turn", "to", "completion", "and", "generate", "each", "end", "of", "turn", "reached", "during", "the", "simulation", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L325-L355
52,573
kobejohn/PQHelper
pqhelper/base.py
Game.all_ends_of_turn
def all_ends_of_turn(self, root): """Simulate the root and continue generating ends of turn until everything has reached mana drain. Warning on random fill: If random fill is used together with this method, it will generate basically forever due to the huge number of possibiliti...
python
def all_ends_of_turn(self, root): """Simulate the root and continue generating ends of turn until everything has reached mana drain. Warning on random fill: If random fill is used together with this method, it will generate basically forever due to the huge number of possibiliti...
[ "def", "all_ends_of_turn", "(", "self", ",", "root", ")", ":", "# simple confirmation that the root is actually a root.", "# otherwise it may seem to work but would be totally out of spec", "if", "root", ".", "parent", ":", "raise", "ValueError", "(", "'Unexpectedly received a no...
Simulate the root and continue generating ends of turn until everything has reached mana drain. Warning on random fill: If random fill is used together with this method, it will generate basically forever due to the huge number of possibilities it introduces. Arguments:...
[ "Simulate", "the", "root", "and", "continue", "generating", "ends", "of", "turn", "until", "everything", "has", "reached", "mana", "drain", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L357-L396
52,574
kobejohn/PQHelper
pqhelper/base.py
Game._simulated_chain_result
def _simulated_chain_result(self, potential_chain, already_used_bonus): """Simulate any chain reactions. Arguments: potential_chain: a state to be tested for chain reactions already_used_bonus: boolean indicating whether a bonus turn was already applied during this action ...
python
def _simulated_chain_result(self, potential_chain, already_used_bonus): """Simulate any chain reactions. Arguments: potential_chain: a state to be tested for chain reactions already_used_bonus: boolean indicating whether a bonus turn was already applied during this action ...
[ "def", "_simulated_chain_result", "(", "self", ",", "potential_chain", ",", "already_used_bonus", ")", ":", "while", "potential_chain", ":", "# hook for capture game optimizations. no effect in base", "# warning: only do this ONCE for any given state or it will", "# always filter the s...
Simulate any chain reactions. Arguments: potential_chain: a state to be tested for chain reactions already_used_bonus: boolean indicating whether a bonus turn was already applied during this action Return: final result state or None (if state is filtered out in capture) ...
[ "Simulate", "any", "chain", "reactions", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L440-L492
52,575
kobejohn/PQHelper
pqhelper/base.py
Game._simulated_EOT
def _simulated_EOT(self, state): """Simulate a normal or mana drain EOT and return it.""" # determine if this is a manadrain or just end of turn is_manadrain = True # default mana drain until valid swap found for swap_pair in state.board.potential_swaps(): result_board, dest...
python
def _simulated_EOT(self, state): """Simulate a normal or mana drain EOT and return it.""" # determine if this is a manadrain or just end of turn is_manadrain = True # default mana drain until valid swap found for swap_pair in state.board.potential_swaps(): result_board, dest...
[ "def", "_simulated_EOT", "(", "self", ",", "state", ")", ":", "# determine if this is a manadrain or just end of turn", "is_manadrain", "=", "True", "# default mana drain until valid swap found", "for", "swap_pair", "in", "state", ".", "board", ".", "potential_swaps", "(", ...
Simulate a normal or mana drain EOT and return it.
[ "Simulate", "a", "normal", "or", "mana", "drain", "EOT", "and", "return", "it", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L500-L517
52,576
kobejohn/PQHelper
pqhelper/base.py
Game._simulated_mana_drain
def _simulated_mana_drain(self, mana_drain_state): """Apply mana drain effects to this state, attach a mana drain EOT and return the mana drain EOT.""" # clear all mana mana_drain_state.player.apply_mana_drain() mana_drain_state.opponent.apply_mana_drain() # force change ...
python
def _simulated_mana_drain(self, mana_drain_state): """Apply mana drain effects to this state, attach a mana drain EOT and return the mana drain EOT.""" # clear all mana mana_drain_state.player.apply_mana_drain() mana_drain_state.opponent.apply_mana_drain() # force change ...
[ "def", "_simulated_mana_drain", "(", "self", ",", "mana_drain_state", ")", ":", "# clear all mana", "mana_drain_state", ".", "player", ".", "apply_mana_drain", "(", ")", "mana_drain_state", ".", "opponent", ".", "apply_mana_drain", "(", ")", "# force change of turn", ...
Apply mana drain effects to this state, attach a mana drain EOT and return the mana drain EOT.
[ "Apply", "mana", "drain", "effects", "to", "this", "state", "attach", "a", "mana", "drain", "EOT", "and", "return", "the", "mana", "drain", "EOT", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L519-L534
52,577
kobejohn/PQHelper
pqhelper/base.py
Board.random_start_board
def random_start_board(cls): """Produce a full, stable start board with random tiles.""" board = cls() board._random_fill() destructions = True # prime the loop while destructions: board, destructions = board.execute_once() board._random_fill() re...
python
def random_start_board(cls): """Produce a full, stable start board with random tiles.""" board = cls() board._random_fill() destructions = True # prime the loop while destructions: board, destructions = board.execute_once() board._random_fill() re...
[ "def", "random_start_board", "(", "cls", ")", ":", "board", "=", "cls", "(", ")", "board", ".", "_random_fill", "(", ")", "destructions", "=", "True", "# prime the loop", "while", "destructions", ":", "board", ",", "destructions", "=", "board", ".", "execute...
Produce a full, stable start board with random tiles.
[ "Produce", "a", "full", "stable", "start", "board", "with", "random", "tiles", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L679-L687
52,578
kobejohn/PQHelper
pqhelper/base.py
Board.execute_once
def execute_once(self, swap=None, spell_changes=None, spell_destructions=None, random_fill=False): """Execute the board only one time. Do not execute chain reactions. Arguments: swap - pair of adjacent positions spell_changes - sequence of (posi...
python
def execute_once(self, swap=None, spell_changes=None, spell_destructions=None, random_fill=False): """Execute the board only one time. Do not execute chain reactions. Arguments: swap - pair of adjacent positions spell_changes - sequence of (posi...
[ "def", "execute_once", "(", "self", ",", "swap", "=", "None", ",", "spell_changes", "=", "None", ",", "spell_destructions", "=", "None", ",", "random_fill", "=", "False", ")", ":", "bcopy", "=", "self", ".", "copy", "(", ")", "# work with a copy, not self", ...
Execute the board only one time. Do not execute chain reactions. Arguments: swap - pair of adjacent positions spell_changes - sequence of (position, tile) changes spell_destructions - sequence of positions to be destroyed Return: (copy of the board, destroyed tile groups)
[ "Execute", "the", "board", "only", "one", "time", ".", "Do", "not", "execute", "chain", "reactions", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L690-L723
52,579
kobejohn/PQHelper
pqhelper/base.py
Board._swap
def _swap(self, swap): """Simulate swapping as in PQ. swap should be a sequence of two positions with a square distance of exactly 1. Non-adjacent swaps cause a ValueError. """ if swap is None: return p1, p2 = swap square_distance = abs(p1[0]...
python
def _swap(self, swap): """Simulate swapping as in PQ. swap should be a sequence of two positions with a square distance of exactly 1. Non-adjacent swaps cause a ValueError. """ if swap is None: return p1, p2 = swap square_distance = abs(p1[0]...
[ "def", "_swap", "(", "self", ",", "swap", ")", ":", "if", "swap", "is", "None", ":", "return", "p1", ",", "p2", "=", "swap", "square_distance", "=", "abs", "(", "p1", "[", "0", "]", "-", "p2", "[", "0", "]", ")", "+", "abs", "(", "p1", "[", ...
Simulate swapping as in PQ. swap should be a sequence of two positions with a square distance of exactly 1. Non-adjacent swaps cause a ValueError.
[ "Simulate", "swapping", "as", "in", "PQ", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L725-L743
52,580
kobejohn/PQHelper
pqhelper/base.py
Board._change
def _change(self, changes): """Apply the given changes to the board. changes: sequence of (position, new tile) pairs or None """ if changes is None: return for position, new_tile in changes: self._array[position] = new_tile
python
def _change(self, changes): """Apply the given changes to the board. changes: sequence of (position, new tile) pairs or None """ if changes is None: return for position, new_tile in changes: self._array[position] = new_tile
[ "def", "_change", "(", "self", ",", "changes", ")", ":", "if", "changes", "is", "None", ":", "return", "for", "position", ",", "new_tile", "in", "changes", ":", "self", ".", "_array", "[", "position", "]", "=", "new_tile" ]
Apply the given changes to the board. changes: sequence of (position, new tile) pairs or None
[ "Apply", "the", "given", "changes", "to", "the", "board", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L745-L753
52,581
kobejohn/PQHelper
pqhelper/base.py
Board._match
def _match(self): """Find all matches and generate a position group for each match.""" #disable optimized matching optimized_rows = None optimized_columns = None for match in self.__match_rows(optimized_rows): #match in rows yield match for match i...
python
def _match(self): """Find all matches and generate a position group for each match.""" #disable optimized matching optimized_rows = None optimized_columns = None for match in self.__match_rows(optimized_rows): #match in rows yield match for match i...
[ "def", "_match", "(", "self", ")", ":", "#disable optimized matching", "optimized_rows", "=", "None", "optimized_columns", "=", "None", "for", "match", "in", "self", ".", "__match_rows", "(", "optimized_rows", ")", ":", "#match in rows", "yield", "match", "for", ...
Find all matches and generate a position group for each match.
[ "Find", "all", "matches", "and", "generate", "a", "position", "group", "for", "each", "match", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L755-L766
52,582
kobejohn/PQHelper
pqhelper/base.py
Board.__match_rows
def __match_rows(self, optimized_lines=None, transpose=False): """Main functionality of _match, but works only on rows. Full matches are found by running this once with original board and once with a transposed board. Arguments: optimized_lines is an optional argument that ident...
python
def __match_rows(self, optimized_lines=None, transpose=False): """Main functionality of _match, but works only on rows. Full matches are found by running this once with original board and once with a transposed board. Arguments: optimized_lines is an optional argument that ident...
[ "def", "__match_rows", "(", "self", ",", "optimized_lines", "=", "None", ",", "transpose", "=", "False", ")", ":", "MIN_LENGTH", "=", "3", "a", "=", "self", ".", "_array", "if", "transpose", ":", "a", "=", "a", ".", "T", "rows", "=", "optimized_lines",...
Main functionality of _match, but works only on rows. Full matches are found by running this once with original board and once with a transposed board. Arguments: optimized_lines is an optional argument that identifies the lines that need to be matched. transpose indica...
[ "Main", "functionality", "of", "_match", "but", "works", "only", "on", "rows", ".", "Full", "matches", "are", "found", "by", "running", "this", "once", "with", "original", "board", "and", "once", "with", "a", "transposed", "board", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L768-L815
52,583
kobejohn/PQHelper
pqhelper/base.py
Board._destroy
def _destroy(self, target_position_groups): """Destroy indicated position groups, handle any chain destructions, and return all destroyed groups.""" target_position_groups = list(target_position_groups) # work on a copy destroyed_tile_groups = list() blank = Tile.singleton('.') ...
python
def _destroy(self, target_position_groups): """Destroy indicated position groups, handle any chain destructions, and return all destroyed groups.""" target_position_groups = list(target_position_groups) # work on a copy destroyed_tile_groups = list() blank = Tile.singleton('.') ...
[ "def", "_destroy", "(", "self", ",", "target_position_groups", ")", ":", "target_position_groups", "=", "list", "(", "target_position_groups", ")", "# work on a copy", "destroyed_tile_groups", "=", "list", "(", ")", "blank", "=", "Tile", ".", "singleton", "(", "'....
Destroy indicated position groups, handle any chain destructions, and return all destroyed groups.
[ "Destroy", "indicated", "position", "groups", "handle", "any", "chain", "destructions", "and", "return", "all", "destroyed", "groups", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L817-L852
52,584
kobejohn/PQHelper
pqhelper/base.py
Board.__skullbomb_radius
def __skullbomb_radius(self, position): """Generate all valid positions in the square around position.""" #get the boundaries of the explosion sb_row, sb_col = position left = max(sb_row - 1, 0) # standard radius or 0 if out of bounds right = min(sb_row + 1, 7) # standard radiu...
python
def __skullbomb_radius(self, position): """Generate all valid positions in the square around position.""" #get the boundaries of the explosion sb_row, sb_col = position left = max(sb_row - 1, 0) # standard radius or 0 if out of bounds right = min(sb_row + 1, 7) # standard radiu...
[ "def", "__skullbomb_radius", "(", "self", ",", "position", ")", ":", "#get the boundaries of the explosion", "sb_row", ",", "sb_col", "=", "position", "left", "=", "max", "(", "sb_row", "-", "1", ",", "0", ")", "# standard radius or 0 if out of bounds", "right", "...
Generate all valid positions in the square around position.
[ "Generate", "all", "valid", "positions", "in", "the", "square", "around", "position", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L854-L864
52,585
kobejohn/PQHelper
pqhelper/base.py
Board._fall
def _fall(self): """Cause tiles to fall down to fill blanks below them.""" a = self._array for column in [a[:, c] for c in range(a.shape[1])]: # find blanks and fill them with tiles above them target_p = column.shape[0] - 1 # start at the bottom fall_distance...
python
def _fall(self): """Cause tiles to fall down to fill blanks below them.""" a = self._array for column in [a[:, c] for c in range(a.shape[1])]: # find blanks and fill them with tiles above them target_p = column.shape[0] - 1 # start at the bottom fall_distance...
[ "def", "_fall", "(", "self", ")", ":", "a", "=", "self", ".", "_array", "for", "column", "in", "[", "a", "[", ":", ",", "c", "]", "for", "c", "in", "range", "(", "a", ".", "shape", "[", "1", "]", ")", "]", ":", "# find blanks and fill them with t...
Cause tiles to fall down to fill blanks below them.
[ "Cause", "tiles", "to", "fall", "down", "to", "fill", "blanks", "below", "them", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L866-L889
52,586
kobejohn/PQHelper
pqhelper/base.py
Board._random_fill
def _random_fill(self): """Fill the board with random tiles based on the Tile class.""" a = self._array for p, tile in self.positions_with_tile(): if tile.is_blank(): a[p] = Tile.random_tile()
python
def _random_fill(self): """Fill the board with random tiles based on the Tile class.""" a = self._array for p, tile in self.positions_with_tile(): if tile.is_blank(): a[p] = Tile.random_tile()
[ "def", "_random_fill", "(", "self", ")", ":", "a", "=", "self", ".", "_array", "for", "p", ",", "tile", "in", "self", ".", "positions_with_tile", "(", ")", ":", "if", "tile", ".", "is_blank", "(", ")", ":", "a", "[", "p", "]", "=", "Tile", ".", ...
Fill the board with random tiles based on the Tile class.
[ "Fill", "the", "board", "with", "random", "tiles", "based", "on", "the", "Tile", "class", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L891-L896
52,587
kobejohn/PQHelper
pqhelper/base.py
Board.potential_swaps
def potential_swaps(self): """Generate a sequence of at least all valid swaps for this board. The built-in optimizer filters out many meaningless swaps, but not all. """ a = self._array rows, cols = a.shape for this_position, tile in self.positions_with_tile(): ...
python
def potential_swaps(self): """Generate a sequence of at least all valid swaps for this board. The built-in optimizer filters out many meaningless swaps, but not all. """ a = self._array rows, cols = a.shape for this_position, tile in self.positions_with_tile(): ...
[ "def", "potential_swaps", "(", "self", ")", ":", "a", "=", "self", ".", "_array", "rows", ",", "cols", "=", "a", ".", "shape", "for", "this_position", ",", "tile", "in", "self", ".", "positions_with_tile", "(", ")", ":", "#produce horizontal swap for this po...
Generate a sequence of at least all valid swaps for this board. The built-in optimizer filters out many meaningless swaps, but not all.
[ "Generate", "a", "sequence", "of", "at", "least", "all", "valid", "swaps", "for", "this", "board", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L915-L933
52,588
kobejohn/PQHelper
pqhelper/base.py
Board._swap_optimizer_allows
def _swap_optimizer_allows(self, p1, p2): """Identify easily discarded meaningless swaps. This is motivated by the cost of millions of swaps being simulated. """ # setup local shortcuts a = self._array tile1 = a[p1] tile2 = a[p2] # 1) disallow same tiles ...
python
def _swap_optimizer_allows(self, p1, p2): """Identify easily discarded meaningless swaps. This is motivated by the cost of millions of swaps being simulated. """ # setup local shortcuts a = self._array tile1 = a[p1] tile2 = a[p2] # 1) disallow same tiles ...
[ "def", "_swap_optimizer_allows", "(", "self", ",", "p1", ",", "p2", ")", ":", "# setup local shortcuts", "a", "=", "self", ".", "_array", "tile1", "=", "a", "[", "p1", "]", "tile2", "=", "a", "[", "p2", "]", "# 1) disallow same tiles", "if", "tile1", "==...
Identify easily discarded meaningless swaps. This is motivated by the cost of millions of swaps being simulated.
[ "Identify", "easily", "discarded", "meaningless", "swaps", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L935-L977
52,589
kobejohn/PQHelper
pqhelper/base.py
Actor.copy
def copy(self): """Return a copy of this actor with the same attribute values.""" health = self.health, self.health_max r = self.r, self.r_max g = self.g, self.g_max b = self.b, self.b_max y = self.y, self.y_max x = self.x, self.x_max m = self.m, self.m_ma...
python
def copy(self): """Return a copy of this actor with the same attribute values.""" health = self.health, self.health_max r = self.r, self.r_max g = self.g, self.g_max b = self.b, self.b_max y = self.y, self.y_max x = self.x, self.x_max m = self.m, self.m_ma...
[ "def", "copy", "(", "self", ")", ":", "health", "=", "self", ".", "health", ",", "self", ".", "health_max", "r", "=", "self", ".", "r", ",", "self", ".", "r_max", "g", "=", "self", ".", "g", ",", "self", ".", "g_max", "b", "=", "self", ".", "...
Return a copy of this actor with the same attribute values.
[ "Return", "a", "copy", "of", "this", "actor", "with", "the", "same", "attribute", "values", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L1017-L1028
52,590
kobejohn/PQHelper
pqhelper/base.py
Actor.apply_mana_drain
def apply_mana_drain(self): """Clear current mana values.""" self.r = self.g = self.b = self.y = 0
python
def apply_mana_drain(self): """Clear current mana values.""" self.r = self.g = self.b = self.y = 0
[ "def", "apply_mana_drain", "(", "self", ")", ":", "self", ".", "r", "=", "self", ".", "g", "=", "self", ".", "b", "=", "self", ".", "y", "=", "0" ]
Clear current mana values.
[ "Clear", "current", "mana", "values", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L1030-L1032
52,591
kobejohn/PQHelper
pqhelper/base.py
Actor.apply_tile_groups
def apply_tile_groups(self, tile_groups): """Increase mana, xp, money, anvils and scrolls based on tile groups.""" self_increase_types = ('r', 'g', 'b', 'y', 'x', 'm', 'h', 'c') attack_types = ('s', '*') total_attack = 0 for tile_group in tile_groups: group_type = Non...
python
def apply_tile_groups(self, tile_groups): """Increase mana, xp, money, anvils and scrolls based on tile groups.""" self_increase_types = ('r', 'g', 'b', 'y', 'x', 'm', 'h', 'c') attack_types = ('s', '*') total_attack = 0 for tile_group in tile_groups: group_type = Non...
[ "def", "apply_tile_groups", "(", "self", ",", "tile_groups", ")", ":", "self_increase_types", "=", "(", "'r'", ",", "'g'", ",", "'b'", ",", "'y'", ",", "'x'", ",", "'m'", ",", "'h'", ",", "'c'", ")", "attack_types", "=", "(", "'s'", ",", "'*'", ")", ...
Increase mana, xp, money, anvils and scrolls based on tile groups.
[ "Increase", "mana", "xp", "money", "anvils", "and", "scrolls", "based", "on", "tile", "groups", "." ]
d2b78a22dcb631794295e6a159b06f39c3f10db6
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L1034-L1073
52,592
MinchinWeb/minchin.releaser
minchin/releaser/vendorize.py
copytree
def copytree(src, dst, overwrite=False, ignore_list=None, debug=False): """ Copy a tree of files over. Ignores a file if it already exists at the destination. """ if ignore_list is None: ignore_list = [] if debug: print('copytree {} to {}'.format(src, dst)) for child in Path...
python
def copytree(src, dst, overwrite=False, ignore_list=None, debug=False): """ Copy a tree of files over. Ignores a file if it already exists at the destination. """ if ignore_list is None: ignore_list = [] if debug: print('copytree {} to {}'.format(src, dst)) for child in Path...
[ "def", "copytree", "(", "src", ",", "dst", ",", "overwrite", "=", "False", ",", "ignore_list", "=", "None", ",", "debug", "=", "False", ")", ":", "if", "ignore_list", "is", "None", ":", "ignore_list", "=", "[", "]", "if", "debug", ":", "print", "(", ...
Copy a tree of files over. Ignores a file if it already exists at the destination.
[ "Copy", "a", "tree", "of", "files", "over", "." ]
cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4
https://github.com/MinchinWeb/minchin.releaser/blob/cfc7f40ac4852b46db98aa1bb8fcaf138a6cdef4/minchin/releaser/vendorize.py#L21-L52
52,593
decryptus/sonicprobe
sonicprobe/libs/moresynchro.py
RWLock.acquire_read
def acquire_read(self, timeout=None): """ Acquire a read lock for the current thread, waiting at most timeout seconds or doing a non-blocking check in case timeout is <= 0. In case timeout is None, the call to acquire_read blocks until the lock request can be serviced. ...
python
def acquire_read(self, timeout=None): """ Acquire a read lock for the current thread, waiting at most timeout seconds or doing a non-blocking check in case timeout is <= 0. In case timeout is None, the call to acquire_read blocks until the lock request can be serviced. ...
[ "def", "acquire_read", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "timeout", "is", "not", "None", ":", "endtime", "=", "time", ".", "time", "(", ")", "+", "timeout", "me", "=", "threading", ".", "currentThread", "(", ")", "self", ".", ...
Acquire a read lock for the current thread, waiting at most timeout seconds or doing a non-blocking check in case timeout is <= 0. In case timeout is None, the call to acquire_read blocks until the lock request can be serviced. If the lock has been successfully acquired, this f...
[ "Acquire", "a", "read", "lock", "for", "the", "current", "thread", "waiting", "at", "most", "timeout", "seconds", "or", "doing", "a", "non", "-", "blocking", "check", "in", "case", "timeout", "is", "<", "=", "0", "." ]
72f73f3a40d2982d79ad68686e36aa31d94b76f8
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/moresynchro.py#L70-L113
52,594
decryptus/sonicprobe
sonicprobe/libs/moresynchro.py
RWLock.acquire_write
def acquire_write(self, timeout=None): """ Acquire a write lock for the current thread, waiting at most timeout seconds or doing a non-blocking check in case timeout is <= 0. In case timeout is None, the call to acquire_write blocks until the lock request can be serviced...
python
def acquire_write(self, timeout=None): """ Acquire a write lock for the current thread, waiting at most timeout seconds or doing a non-blocking check in case timeout is <= 0. In case timeout is None, the call to acquire_write blocks until the lock request can be serviced...
[ "def", "acquire_write", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "timeout", "is", "not", "None", ":", "endtime", "=", "time", ".", "time", "(", ")", "+", "timeout", "me", "=", "threading", ".", "currentThread", "(", ")", "self", ".",...
Acquire a write lock for the current thread, waiting at most timeout seconds or doing a non-blocking check in case timeout is <= 0. In case timeout is None, the call to acquire_write blocks until the lock request can be serviced. If the lock has been successfully acquired, this...
[ "Acquire", "a", "write", "lock", "for", "the", "current", "thread", "waiting", "at", "most", "timeout", "seconds", "or", "doing", "a", "non", "-", "blocking", "check", "in", "case", "timeout", "is", "<", "=", "0", "." ]
72f73f3a40d2982d79ad68686e36aa31d94b76f8
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/moresynchro.py#L115-L156
52,595
decryptus/sonicprobe
sonicprobe/libs/moresynchro.py
RWLock.release
def release(self): """ Release the currently held lock. In case the current thread holds no lock, a thread.error is thrown. """ me = threading.currentThread() self.__condition.acquire() try: if self.__writer is me: self.__write...
python
def release(self): """ Release the currently held lock. In case the current thread holds no lock, a thread.error is thrown. """ me = threading.currentThread() self.__condition.acquire() try: if self.__writer is me: self.__write...
[ "def", "release", "(", "self", ")", ":", "me", "=", "threading", ".", "currentThread", "(", ")", "self", ".", "__condition", ".", "acquire", "(", ")", "try", ":", "if", "self", ".", "__writer", "is", "me", ":", "self", ".", "__writer_lock_count", "-=",...
Release the currently held lock. In case the current thread holds no lock, a thread.error is thrown.
[ "Release", "the", "currently", "held", "lock", "." ]
72f73f3a40d2982d79ad68686e36aa31d94b76f8
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/moresynchro.py#L158-L182
52,596
decryptus/sonicprobe
sonicprobe/libs/moresynchro.py
ListLock.try_acquire
def try_acquire(self, elt): """ elt must be hashable. If not yet locked, elt is captured for the current thread and True is returned. If already locked by the current thread its recursive counter is incremented and True is returned. If already locked by another...
python
def try_acquire(self, elt): """ elt must be hashable. If not yet locked, elt is captured for the current thread and True is returned. If already locked by the current thread its recursive counter is incremented and True is returned. If already locked by another...
[ "def", "try_acquire", "(", "self", ",", "elt", ")", ":", "me", "=", "threading", ".", "currentThread", "(", ")", "self", ".", "lock", ".", "acquire", "(", ")", "try", ":", "if", "elt", "not", "in", "self", ".", "locked", ":", "self", ".", "locked",...
elt must be hashable. If not yet locked, elt is captured for the current thread and True is returned. If already locked by the current thread its recursive counter is incremented and True is returned. If already locked by another thread False is returned.
[ "elt", "must", "be", "hashable", "." ]
72f73f3a40d2982d79ad68686e36aa31d94b76f8
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/moresynchro.py#L192-L215
52,597
dev-pipeline/dev-pipeline-configure
lib/devpipeline_configure/cache.py
_CachedComponent.get
def get(self, key, raw=False, fallback=None): """ Get a string value from the componnet. Arguments: key - the key to retrieve raw - Control whether the value is interpolated or returned raw. By default, values are interpolated. fallback - The return value ...
python
def get(self, key, raw=False, fallback=None): """ Get a string value from the componnet. Arguments: key - the key to retrieve raw - Control whether the value is interpolated or returned raw. By default, values are interpolated. fallback - The return value ...
[ "def", "get", "(", "self", ",", "key", ",", "raw", "=", "False", ",", "fallback", "=", "None", ")", ":", "return", "self", ".", "_component", ".", "get", "(", "key", ",", "raw", "=", "raw", ",", "fallback", "=", "fallback", ")" ]
Get a string value from the componnet. Arguments: key - the key to retrieve raw - Control whether the value is interpolated or returned raw. By default, values are interpolated. fallback - The return value if key isn't in the component.
[ "Get", "a", "string", "value", "from", "the", "componnet", "." ]
26de2dd1b39d9a77d5417244f09319e7dce47495
https://github.com/dev-pipeline/dev-pipeline-configure/blob/26de2dd1b39d9a77d5417244f09319e7dce47495/lib/devpipeline_configure/cache.py#L31-L41
52,598
dev-pipeline/dev-pipeline-configure
lib/devpipeline_configure/cache.py
_CachedComponent.get_list
def get_list(self, key, fallback=None, split=","): """ Retrieve a value in list form. The interpolated value will be split on some key (by default, ',') and the resulting list will be returned. Arguments: key - the key to return fallback - The result to return i...
python
def get_list(self, key, fallback=None, split=","): """ Retrieve a value in list form. The interpolated value will be split on some key (by default, ',') and the resulting list will be returned. Arguments: key - the key to return fallback - The result to return i...
[ "def", "get_list", "(", "self", ",", "key", ",", "fallback", "=", "None", ",", "split", "=", "\",\"", ")", ":", "fallback", "=", "fallback", "or", "[", "]", "raw", "=", "self", ".", "get", "(", "key", ",", "None", ")", "if", "raw", ":", "return",...
Retrieve a value in list form. The interpolated value will be split on some key (by default, ',') and the resulting list will be returned. Arguments: key - the key to return fallback - The result to return if key isn't in the component. By default, this will...
[ "Retrieve", "a", "value", "in", "list", "form", "." ]
26de2dd1b39d9a77d5417244f09319e7dce47495
https://github.com/dev-pipeline/dev-pipeline-configure/blob/26de2dd1b39d9a77d5417244f09319e7dce47495/lib/devpipeline_configure/cache.py#L43-L60
52,599
dev-pipeline/dev-pipeline-configure
lib/devpipeline_configure/cache.py
_CachedComponent.set
def set(self, key, value): """ Set a value in the component. Arguments: key - the key to set value - the new value """ if self._component.get(key, raw=True) != value: self._component[key] = value self._main_config.dirty = True
python
def set(self, key, value): """ Set a value in the component. Arguments: key - the key to set value - the new value """ if self._component.get(key, raw=True) != value: self._component[key] = value self._main_config.dirty = True
[ "def", "set", "(", "self", ",", "key", ",", "value", ")", ":", "if", "self", ".", "_component", ".", "get", "(", "key", ",", "raw", "=", "True", ")", "!=", "value", ":", "self", ".", "_component", "[", "key", "]", "=", "value", "self", ".", "_m...
Set a value in the component. Arguments: key - the key to set value - the new value
[ "Set", "a", "value", "in", "the", "component", "." ]
26de2dd1b39d9a77d5417244f09319e7dce47495
https://github.com/dev-pipeline/dev-pipeline-configure/blob/26de2dd1b39d9a77d5417244f09319e7dce47495/lib/devpipeline_configure/cache.py#L62-L72