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
54,700
475Cumulus/TBone
tbone/resources/mongo.py
MongoResource.build_filters
def build_filters(self, **kwargs): ''' Break url parameters and turn into filters ''' filters = {} for param, value in kwargs.items(): # break each url parameter to key + operator (if exists) pl = dict(enumerate(param.split('__'))) key = pl[0] oper...
python
def build_filters(self, **kwargs): ''' Break url parameters and turn into filters ''' filters = {} for param, value in kwargs.items(): # break each url parameter to key + operator (if exists) pl = dict(enumerate(param.split('__'))) key = pl[0] oper...
[ "def", "build_filters", "(", "self", ",", "*", "*", "kwargs", ")", ":", "filters", "=", "{", "}", "for", "param", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "# break each url parameter to key + operator (if exists)", "pl", "=", "dict", "(", ...
Break url parameters and turn into filters
[ "Break", "url", "parameters", "and", "turn", "into", "filters" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/mongo.py#L195-L219
54,701
475Cumulus/TBone
tbone/resources/mongo.py
MongoResource.build_sort
def build_sort(self, **kwargs): ''' Break url parameters and turn into sort arguments ''' sort = [] order = kwargs.get('order_by', None) if order: if type(order) is list: order = order[0] if order[:1] == '-': sort.append((order[1:],...
python
def build_sort(self, **kwargs): ''' Break url parameters and turn into sort arguments ''' sort = [] order = kwargs.get('order_by', None) if order: if type(order) is list: order = order[0] if order[:1] == '-': sort.append((order[1:],...
[ "def", "build_sort", "(", "self", ",", "*", "*", "kwargs", ")", ":", "sort", "=", "[", "]", "order", "=", "kwargs", ".", "get", "(", "'order_by'", ",", "None", ")", "if", "order", ":", "if", "type", "(", "order", ")", "is", "list", ":", "order", ...
Break url parameters and turn into sort arguments
[ "Break", "url", "parameters", "and", "turn", "into", "sort", "arguments" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/mongo.py#L229-L240
54,702
475Cumulus/TBone
tbone/data/models.py
ModelSerializer.serialize
async def serialize(self, native=False): ''' Returns a serialized from of the model taking into account projection rules and ``@serialize`` decorated methods. :param native: Deternines if data is serialized to Python native types or primitive form. Defaults to ``False`` ...
python
async def serialize(self, native=False): ''' Returns a serialized from of the model taking into account projection rules and ``@serialize`` decorated methods. :param native: Deternines if data is serialized to Python native types or primitive form. Defaults to ``False`` ...
[ "async", "def", "serialize", "(", "self", ",", "native", "=", "False", ")", ":", "data", "=", "{", "}", "# iterate through all fields", "for", "field_name", ",", "field", "in", "self", ".", "_fields", ".", "items", "(", ")", ":", "# serialize field data", ...
Returns a serialized from of the model taking into account projection rules and ``@serialize`` decorated methods. :param native: Deternines if data is serialized to Python native types or primitive form. Defaults to ``False``
[ "Returns", "a", "serialized", "from", "of", "the", "model", "taking", "into", "account", "projection", "rules", "and" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/data/models.py#L134-L157
54,703
475Cumulus/TBone
tbone/data/models.py
ModelSerializer.deserialize
async def deserialize(self, data: dict, silent=True): ''' Deserializes a Python ``dict`` into the model by assigning values to their respective fields. Ignores data attributes that do not match one of the Model's fields. Ignores data attributes who's matching fields are declared with the...
python
async def deserialize(self, data: dict, silent=True): ''' Deserializes a Python ``dict`` into the model by assigning values to their respective fields. Ignores data attributes that do not match one of the Model's fields. Ignores data attributes who's matching fields are declared with the...
[ "async", "def", "deserialize", "(", "self", ",", "data", ":", "dict", ",", "silent", "=", "True", ")", ":", "self", ".", "import_data", "(", "self", ".", "_deserialize", "(", "data", ")", ")", "self", ".", "validate", "(", ")" ]
Deserializes a Python ``dict`` into the model by assigning values to their respective fields. Ignores data attributes that do not match one of the Model's fields. Ignores data attributes who's matching fields are declared with the ``readonly`` attribute Validates the data after import. O...
[ "Deserializes", "a", "Python", "dict", "into", "the", "model", "by", "assigning", "values", "to", "their", "respective", "fields", ".", "Ignores", "data", "attributes", "that", "do", "not", "match", "one", "of", "the", "Model", "s", "fields", ".", "Ignores",...
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/data/models.py#L159-L177
54,704
475Cumulus/TBone
tbone/data/models.py
ModelSerializer._deserialize
def _deserialize(self, data: dict, silent=True) -> dict: ''' Internal deserialize method for sifting out unacceptable data for the model ''' deserialized_data = {} for name, field in self._fields.items(): if field._readonly is False and name in data: deserialized_data...
python
def _deserialize(self, data: dict, silent=True) -> dict: ''' Internal deserialize method for sifting out unacceptable data for the model ''' deserialized_data = {} for name, field in self._fields.items(): if field._readonly is False and name in data: deserialized_data...
[ "def", "_deserialize", "(", "self", ",", "data", ":", "dict", ",", "silent", "=", "True", ")", "->", "dict", ":", "deserialized_data", "=", "{", "}", "for", "name", ",", "field", "in", "self", ".", "_fields", ".", "items", "(", ")", ":", "if", "fie...
Internal deserialize method for sifting out unacceptable data for the model
[ "Internal", "deserialize", "method", "for", "sifting", "out", "unacceptable", "data", "for", "the", "model" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/data/models.py#L179-L185
54,705
475Cumulus/TBone
tbone/data/models.py
Model.import_data
def import_data(self, data: dict): ''' Imports data into model and converts to python form. Model fields and container of model fields retain their model class structure. Merges with existing if data is partial ''' if not isinstance(data, dict): raise ValueErr...
python
def import_data(self, data: dict): ''' Imports data into model and converts to python form. Model fields and container of model fields retain their model class structure. Merges with existing if data is partial ''' if not isinstance(data, dict): raise ValueErr...
[ "def", "import_data", "(", "self", ",", "data", ":", "dict", ")", ":", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", "raise", "ValueError", "(", "'Cannot import data not as dict'", ")", "self", ".", "_data", ".", "update", "(", "data", "...
Imports data into model and converts to python form. Model fields and container of model fields retain their model class structure. Merges with existing if data is partial
[ "Imports", "data", "into", "model", "and", "converts", "to", "python", "form", ".", "Model", "fields", "and", "container", "of", "model", "fields", "retain", "their", "model", "class", "structure", ".", "Merges", "with", "existing", "if", "data", "is", "part...
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/data/models.py#L275-L286
54,706
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/system.py
System.maintenance_mode
def maintenance_mode(self, **kwargs): """Configures maintenance mode on the device Args: rbridge_id (str): The rbridge ID of the device on which Maintenance mode will be configured in a VCS fabric. get (bool): Get config instead of editing config. (T...
python
def maintenance_mode(self, **kwargs): """Configures maintenance mode on the device Args: rbridge_id (str): The rbridge ID of the device on which Maintenance mode will be configured in a VCS fabric. get (bool): Get config instead of editing config. (T...
[ "def", "maintenance_mode", "(", "self", ",", "*", "*", "kwargs", ")", ":", "is_get_config", "=", "kwargs", ".", "pop", "(", "'get'", ",", "False", ")", "delete", "=", "kwargs", ".", "pop", "(", "'delete'", ",", "False", ")", "rbridge_id", "=", "kwargs"...
Configures maintenance mode on the device Args: rbridge_id (str): The rbridge ID of the device on which Maintenance mode will be configured in a VCS fabric. get (bool): Get config instead of editing config. (True, False) callback (function): A fu...
[ "Configures", "maintenance", "mode", "on", "the", "device" ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/system.py#L29-L85
54,707
brocade/pynos
pynos/device.py
Device.firmware_version
def firmware_version(self): """ Returns firmware version. Args: None Returns: Dictionary Raises: None """ namespace = "urn:brocade.com:mgmt:brocade-firmware-ext" request_ver = ET.Element("show-firmware-version", xmln...
python
def firmware_version(self): """ Returns firmware version. Args: None Returns: Dictionary Raises: None """ namespace = "urn:brocade.com:mgmt:brocade-firmware-ext" request_ver = ET.Element("show-firmware-version", xmln...
[ "def", "firmware_version", "(", "self", ")", ":", "namespace", "=", "\"urn:brocade.com:mgmt:brocade-firmware-ext\"", "request_ver", "=", "ET", ".", "Element", "(", "\"show-firmware-version\"", ",", "xmlns", "=", "namespace", ")", "ver", "=", "self", ".", "_callback"...
Returns firmware version. Args: None Returns: Dictionary Raises: None
[ "Returns", "firmware", "version", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/device.py#L251-L269
54,708
brocade/pynos
pynos/device.py
Device._callback_main
def _callback_main(self, call, handler='edit_config', target='running', source='startup'): """ Callback for NETCONF calls. Args: call: An Element Tree element containing the XML of the NETCONF call you intend to make to the device. ...
python
def _callback_main(self, call, handler='edit_config', target='running', source='startup'): """ Callback for NETCONF calls. Args: call: An Element Tree element containing the XML of the NETCONF call you intend to make to the device. ...
[ "def", "_callback_main", "(", "self", ",", "call", ",", "handler", "=", "'edit_config'", ",", "target", "=", "'running'", ",", "source", "=", "'startup'", ")", ":", "try", ":", "if", "handler", "==", "'get_config'", ":", "call", "=", "ET", ".", "tostring...
Callback for NETCONF calls. Args: call: An Element Tree element containing the XML of the NETCONF call you intend to make to the device. handler: Type of ncclient call to make. get_config: NETCONF standard get config. get: ncclient dispatc...
[ "Callback", "for", "NETCONF", "calls", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/device.py#L271-L317
54,709
brocade/pynos
pynos/device.py
Device.reconnect
def reconnect(self): """ Reconnect session with device. Args: None Returns: bool: True if reconnect succeeds, False if not. Raises: None """ if self._auth_method is "userpass": self._mgr = manager.connect(host=sel...
python
def reconnect(self): """ Reconnect session with device. Args: None Returns: bool: True if reconnect succeeds, False if not. Raises: None """ if self._auth_method is "userpass": self._mgr = manager.connect(host=sel...
[ "def", "reconnect", "(", "self", ")", ":", "if", "self", ".", "_auth_method", "is", "\"userpass\"", ":", "self", ".", "_mgr", "=", "manager", ".", "connect", "(", "host", "=", "self", ".", "_conn", "[", "0", "]", ",", "port", "=", "self", ".", "_co...
Reconnect session with device. Args: None Returns: bool: True if reconnect succeeds, False if not. Raises: None
[ "Reconnect", "session", "with", "device", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/device.py#L338-L367
54,710
brocade/pynos
pynos/device.py
Device.find_interface_by_mac
def find_interface_by_mac(self, **kwargs): """Find the interface through which a MAC can be reached. Args: mac_address (str): A MAC address in 'xx:xx:xx:xx:xx:xx' format. Returns: list[dict]: a list of mac table data. Raises: KeyError: if `mac_addre...
python
def find_interface_by_mac(self, **kwargs): """Find the interface through which a MAC can be reached. Args: mac_address (str): A MAC address in 'xx:xx:xx:xx:xx:xx' format. Returns: list[dict]: a list of mac table data. Raises: KeyError: if `mac_addre...
[ "def", "find_interface_by_mac", "(", "self", ",", "*", "*", "kwargs", ")", ":", "mac", "=", "kwargs", ".", "pop", "(", "'mac_address'", ")", "results", "=", "[", "x", "for", "x", "in", "self", ".", "mac_table", "if", "x", "[", "'mac_address'", "]", "...
Find the interface through which a MAC can be reached. Args: mac_address (str): A MAC address in 'xx:xx:xx:xx:xx:xx' format. Returns: list[dict]: a list of mac table data. Raises: KeyError: if `mac_address` is not specified. Examples: >...
[ "Find", "the", "interface", "through", "which", "a", "MAC", "can", "be", "reached", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/device.py#L369-L394
54,711
kdeldycke/chessboard
chessboard/cli.py
solve
def solve(ctx, length, height, silent, profile, **pieces): """ Solve a puzzle constrained by board dimensions and pieces. """ # Check that at least one piece is provided. if not sum(pieces.values()): context = click.get_current_context() raise BadParameter('No piece provided.', ctx=context, ...
python
def solve(ctx, length, height, silent, profile, **pieces): """ Solve a puzzle constrained by board dimensions and pieces. """ # Check that at least one piece is provided. if not sum(pieces.values()): context = click.get_current_context() raise BadParameter('No piece provided.', ctx=context, ...
[ "def", "solve", "(", "ctx", ",", "length", ",", "height", ",", "silent", ",", "profile", ",", "*", "*", "pieces", ")", ":", "# Check that at least one piece is provided.", "if", "not", "sum", "(", "pieces", ".", "values", "(", ")", ")", ":", "context", "...
Solve a puzzle constrained by board dimensions and pieces.
[ "Solve", "a", "puzzle", "constrained", "by", "board", "dimensions", "and", "pieces", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/cli.py#L112-L139
54,712
kdeldycke/chessboard
chessboard/cli.py
benchmark
def benchmark(): """ Run a benchmarking suite and measure time taken by the solver. Each scenario is run in an isolated process, and results are appended to CSV file. """ # Use all cores but one on multi-core CPUs. pool_size = multiprocessing.cpu_count() - 1 if pool_size < 1: pool_s...
python
def benchmark(): """ Run a benchmarking suite and measure time taken by the solver. Each scenario is run in an isolated process, and results are appended to CSV file. """ # Use all cores but one on multi-core CPUs. pool_size = multiprocessing.cpu_count() - 1 if pool_size < 1: pool_s...
[ "def", "benchmark", "(", ")", ":", "# Use all cores but one on multi-core CPUs.", "pool_size", "=", "multiprocessing", ".", "cpu_count", "(", ")", "-", "1", "if", "pool_size", "<", "1", ":", "pool_size", "=", "1", "# Start a pool of workers. Only allow 1 task per child,...
Run a benchmarking suite and measure time taken by the solver. Each scenario is run in an isolated process, and results are appended to CSV file.
[ "Run", "a", "benchmarking", "suite", "and", "measure", "time", "taken", "by", "the", "solver", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/cli.py#L143-L165
54,713
kdeldycke/chessboard
chessboard/cli.py
PositiveInt.convert
def convert(self, value, param, ctx): """ Reuse standard integer validator but add checks on sign and zero. """ value = super(PositiveInt, self).convert(value, param, ctx) if value < 0: self.fail('%s is not positive' % value, param, ctx) if not self.allow_zero and not...
python
def convert(self, value, param, ctx): """ Reuse standard integer validator but add checks on sign and zero. """ value = super(PositiveInt, self).convert(value, param, ctx) if value < 0: self.fail('%s is not positive' % value, param, ctx) if not self.allow_zero and not...
[ "def", "convert", "(", "self", ",", "value", ",", "param", ",", "ctx", ")", ":", "value", "=", "super", "(", "PositiveInt", ",", "self", ")", ".", "convert", "(", "value", ",", "param", ",", "ctx", ")", "if", "value", "<", "0", ":", "self", ".", ...
Reuse standard integer validator but add checks on sign and zero.
[ "Reuse", "standard", "integer", "validator", "but", "add", "checks", "on", "sign", "and", "zero", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/cli.py#L44-L52
54,714
brocade/pynos
pynos/versions/base/services.py
Services.vrrp
def vrrp(self, **kwargs): """Enable or Disable VRRP. Args: ip_version (str): The IP version ('4' or '6') for which VRRP should be enabled/disabled. Default: `4`. enabled (bool): If VRRP should be enabled or disabled. Default: ``True``. ...
python
def vrrp(self, **kwargs): """Enable or Disable VRRP. Args: ip_version (str): The IP version ('4' or '6') for which VRRP should be enabled/disabled. Default: `4`. enabled (bool): If VRRP should be enabled or disabled. Default: ``True``. ...
[ "def", "vrrp", "(", "self", ",", "*", "*", "kwargs", ")", ":", "ip_version", "=", "kwargs", ".", "pop", "(", "'ip_version'", ",", "'4'", ")", "enabled", "=", "kwargs", ".", "pop", "(", "'enabled'", ",", "True", ")", "rbridge_id", "=", "kwargs", ".", ...
Enable or Disable VRRP. Args: ip_version (str): The IP version ('4' or '6') for which VRRP should be enabled/disabled. Default: `4`. enabled (bool): If VRRP should be enabled or disabled. Default: ``True``. rbridge_id (str): The rbridge ID o...
[ "Enable", "or", "Disable", "VRRP", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/services.py#L74-L124
54,715
kdeldycke/chessboard
chessboard/benchmark.py
run_scenario
def run_scenario(params): """ Run one scenario and returns execution time and number of solutions. Also returns initial parameters in the response to keep the results associated with the initial context. """ solver = SolverContext(**params) start = time.time() count = sum(1 for _ in solver....
python
def run_scenario(params): """ Run one scenario and returns execution time and number of solutions. Also returns initial parameters in the response to keep the results associated with the initial context. """ solver = SolverContext(**params) start = time.time() count = sum(1 for _ in solver....
[ "def", "run_scenario", "(", "params", ")", ":", "solver", "=", "SolverContext", "(", "*", "*", "params", ")", "start", "=", "time", ".", "time", "(", ")", "count", "=", "sum", "(", "1", "for", "_", "in", "solver", ".", "solve", "(", ")", ")", "ex...
Run one scenario and returns execution time and number of solutions. Also returns initial parameters in the response to keep the results associated with the initial context.
[ "Run", "one", "scenario", "and", "returns", "execution", "time", "and", "number", "of", "solutions", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/benchmark.py#L43-L56
54,716
kdeldycke/chessboard
chessboard/benchmark.py
Benchmark.load_csv
def load_csv(self): """ Load old benchmark results from CSV. """ if path.exists(self.csv_filepath): self.results = self.results.append( pandas.read_csv(self.csv_filepath))
python
def load_csv(self): """ Load old benchmark results from CSV. """ if path.exists(self.csv_filepath): self.results = self.results.append( pandas.read_csv(self.csv_filepath))
[ "def", "load_csv", "(", "self", ")", ":", "if", "path", ".", "exists", "(", "self", ".", "csv_filepath", ")", ":", "self", ".", "results", "=", "self", ".", "results", ".", "append", "(", "pandas", ".", "read_csv", "(", "self", ".", "csv_filepath", "...
Load old benchmark results from CSV.
[ "Load", "old", "benchmark", "results", "from", "CSV", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/benchmark.py#L122-L126
54,717
kdeldycke/chessboard
chessboard/benchmark.py
Benchmark.add
def add(self, new_results): """ Add new benchmark results. """ for result in new_results: result.update(self.context) self.results = self.results.append(result, ignore_index=True)
python
def add(self, new_results): """ Add new benchmark results. """ for result in new_results: result.update(self.context) self.results = self.results.append(result, ignore_index=True)
[ "def", "add", "(", "self", ",", "new_results", ")", ":", "for", "result", "in", "new_results", ":", "result", ".", "update", "(", "self", ".", "context", ")", "self", ".", "results", "=", "self", ".", "results", ".", "append", "(", "result", ",", "ig...
Add new benchmark results.
[ "Add", "new", "benchmark", "results", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/benchmark.py#L128-L132
54,718
kdeldycke/chessboard
chessboard/benchmark.py
Benchmark.save_csv
def save_csv(self): """ Dump all results to CSV. """ # Sort results so we can start to see patterns right in the raw CSV. self.results.sort_values(by=self.column_ids, inplace=True) # Gotcha: integers seems to be promoted to float64 because of # reindexation. See: https://pandas.p...
python
def save_csv(self): """ Dump all results to CSV. """ # Sort results so we can start to see patterns right in the raw CSV. self.results.sort_values(by=self.column_ids, inplace=True) # Gotcha: integers seems to be promoted to float64 because of # reindexation. See: https://pandas.p...
[ "def", "save_csv", "(", "self", ")", ":", "# Sort results so we can start to see patterns right in the raw CSV.", "self", ".", "results", ".", "sort_values", "(", "by", "=", "self", ".", "column_ids", ",", "inplace", "=", "True", ")", "# Gotcha: integers seems to be pro...
Dump all results to CSV.
[ "Dump", "all", "results", "to", "CSV", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/benchmark.py#L134-L142
54,719
kdeldycke/chessboard
chessboard/benchmark.py
Benchmark.nqueen_graph
def nqueen_graph(self): """ Graph n-queens problem for the current version and context. """ # Filters out boards with pieces other than queens. nqueens = self.results for piece_label in set(PIECE_LABELS).difference(['queen']): nqueens = nqueens[nqueens[piece_label].map(pandas...
python
def nqueen_graph(self): """ Graph n-queens problem for the current version and context. """ # Filters out boards with pieces other than queens. nqueens = self.results for piece_label in set(PIECE_LABELS).difference(['queen']): nqueens = nqueens[nqueens[piece_label].map(pandas...
[ "def", "nqueen_graph", "(", "self", ")", ":", "# Filters out boards with pieces other than queens.", "nqueens", "=", "self", ".", "results", "for", "piece_label", "in", "set", "(", "PIECE_LABELS", ")", ".", "difference", "(", "[", "'queen'", "]", ")", ":", "nque...
Graph n-queens problem for the current version and context.
[ "Graph", "n", "-", "queens", "problem", "for", "the", "current", "version", "and", "context", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/benchmark.py#L144-L175
54,720
brocade/pynos
pynos/versions/ver_7/ver_7_0_0/bgp.py
BGP.neighbor
def neighbor(self, **kwargs): """Experimental neighbor method. Args: ip_addr (str): IP Address of BGP neighbor. remote_as (str): Remote ASN of BGP neighbor. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric...
python
def neighbor(self, **kwargs): """Experimental neighbor method. Args: ip_addr (str): IP Address of BGP neighbor. remote_as (str): Remote ASN of BGP neighbor. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric...
[ "def", "neighbor", "(", "self", ",", "*", "*", "kwargs", ")", ":", "ip_addr", "=", "ip_interface", "(", "unicode", "(", "kwargs", ".", "pop", "(", "'ip_addr'", ")", ")", ")", "rbridge_id", "=", "kwargs", ".", "pop", "(", "'rbridge_id'", ",", "'1'", "...
Experimental neighbor method. Args: ip_addr (str): IP Address of BGP neighbor. remote_as (str): Remote ASN of BGP neighbor. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. afis (list): A list of AFIs...
[ "Experimental", "neighbor", "method", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_0_0/bgp.py#L36-L108
54,721
brocade/pynos
pynos/versions/ver_7/ver_7_0_0/bgp.py
BGP.evpn_afi_peer_activate
def evpn_afi_peer_activate(self, **kwargs): """ Activate EVPN AFI for a peer. Args: ip_addr (str): IP Address of BGP neighbor. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. delete (bool): Delet...
python
def evpn_afi_peer_activate(self, **kwargs): """ Activate EVPN AFI for a peer. Args: ip_addr (str): IP Address of BGP neighbor. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. delete (bool): Delet...
[ "def", "evpn_afi_peer_activate", "(", "self", ",", "*", "*", "kwargs", ")", ":", "peer_ip", "=", "kwargs", ".", "pop", "(", "'peer_ip'", ")", "callback", "=", "kwargs", ".", "pop", "(", "'callback'", ",", "self", ".", "_callback", ")", "evpn_activate", "...
Activate EVPN AFI for a peer. Args: ip_addr (str): IP Address of BGP neighbor. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. delete (bool): Deletes the neighbor if `delete` is ``True``. Deactiv...
[ "Activate", "EVPN", "AFI", "for", "a", "peer", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_0_0/bgp.py#L186-L242
54,722
brocade/pynos
pynos/versions/ver_7/ver_7_0_0/bgp.py
BGP.evpn_next_hop_unchanged
def evpn_next_hop_unchanged(self, **kwargs): """Configure next hop unchanged for an EVPN neighbor. You probably don't want this method. You probably want to configure an EVPN neighbor using `BGP.neighbor`. That will configure next-hop unchanged automatically. Args: ...
python
def evpn_next_hop_unchanged(self, **kwargs): """Configure next hop unchanged for an EVPN neighbor. You probably don't want this method. You probably want to configure an EVPN neighbor using `BGP.neighbor`. That will configure next-hop unchanged automatically. Args: ...
[ "def", "evpn_next_hop_unchanged", "(", "self", ",", "*", "*", "kwargs", ")", ":", "callback", "=", "kwargs", ".", "pop", "(", "'callback'", ",", "self", ".", "_callback", ")", "args", "=", "dict", "(", "rbridge_id", "=", "kwargs", ".", "pop", "(", "'rb...
Configure next hop unchanged for an EVPN neighbor. You probably don't want this method. You probably want to configure an EVPN neighbor using `BGP.neighbor`. That will configure next-hop unchanged automatically. Args: ip_addr (str): IP Address of BGP neighbor. ...
[ "Configure", "next", "hop", "unchanged", "for", "an", "EVPN", "neighbor", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_0_0/bgp.py#L436-L487
54,723
brocade/pynos
pynos/versions/ver_7/ver_7_0_0/bgp.py
BGP.enable_peer_bfd
def enable_peer_bfd(self, **kwargs): """BFD enable for each specified peer. Args: rbridge_id (str): Rbridge to configure. (1, 225, etc) peer_ip (str): Peer IPv4 address for BFD setting. delete (bool): True if BFD configuration should be deleted. Defa...
python
def enable_peer_bfd(self, **kwargs): """BFD enable for each specified peer. Args: rbridge_id (str): Rbridge to configure. (1, 225, etc) peer_ip (str): Peer IPv4 address for BFD setting. delete (bool): True if BFD configuration should be deleted. Defa...
[ "def", "enable_peer_bfd", "(", "self", ",", "*", "*", "kwargs", ")", ":", "method_name", "=", "'rbridge_id_router_router_bgp_router_bgp_attributes_'", "'neighbor_neighbor_ips_neighbor_addr_bfd_bfd_enable'", "bfd_enable", "=", "getattr", "(", "self", ".", "_rbridge", ",", ...
BFD enable for each specified peer. Args: rbridge_id (str): Rbridge to configure. (1, 225, etc) peer_ip (str): Peer IPv4 address for BFD setting. delete (bool): True if BFD configuration should be deleted. Default value will be False if not specified. ...
[ "BFD", "enable", "for", "each", "specified", "peer", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_0_0/bgp.py#L733-L781
54,724
brocade/pynos
pynos/versions/ver_7/ver_7_0_0/bgp.py
BGP._peer_get_bfd
def _peer_get_bfd(self, tx, rx, multiplier): """Get and merge the `bfd` config from global BGP. You should not use this method. You probably want `BGP.bfd`. Args: tx: XML document with the XML to get the transmit interval. rx: XML document with the XML to get th...
python
def _peer_get_bfd(self, tx, rx, multiplier): """Get and merge the `bfd` config from global BGP. You should not use this method. You probably want `BGP.bfd`. Args: tx: XML document with the XML to get the transmit interval. rx: XML document with the XML to get th...
[ "def", "_peer_get_bfd", "(", "self", ",", "tx", ",", "rx", ",", "multiplier", ")", ":", "tx", "=", "self", ".", "_callback", "(", "tx", ",", "handler", "=", "'get_config'", ")", "rx", "=", "self", ".", "_callback", "(", "rx", ",", "handler", "=", "...
Get and merge the `bfd` config from global BGP. You should not use this method. You probably want `BGP.bfd`. Args: tx: XML document with the XML to get the transmit interval. rx: XML document with the XML to get the receive interval. multiplier: XML document...
[ "Get", "and", "merge", "the", "bfd", "config", "from", "global", "BGP", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_0_0/bgp.py#L864-L889
54,725
brocade/pynos
pynos/versions/ver_7/ver_7_0_0/bgp.py
BGP.vrf_max_paths
def vrf_max_paths(self, **kwargs): """Set BGP max paths property on VRF address family. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. paths (str): Number ...
python
def vrf_max_paths(self, **kwargs): """Set BGP max paths property on VRF address family. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. paths (str): Number ...
[ "def", "vrf_max_paths", "(", "self", ",", "*", "*", "kwargs", ")", ":", "afi", "=", "kwargs", ".", "pop", "(", "'afi'", ",", "'ipv4'", ")", "vrf", "=", "kwargs", ".", "pop", "(", "'vrf'", ",", "'default'", ")", "get_config", "=", "kwargs", ".", "po...
Set BGP max paths property on VRF address family. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. paths (str): Number of paths for BGP ECMP (default: 8). ...
[ "Set", "BGP", "max", "paths", "property", "on", "VRF", "address", "family", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_0_0/bgp.py#L1124-L1211
54,726
brocade/pynos
pynos/versions/ver_7/ver_7_0_0/bgp.py
BGP.default_vrf_max_paths
def default_vrf_max_paths(self, **kwargs): """Set BGP max paths property on default VRF address family. Args: rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. paths (str): Number of paths for BGP ECMP (default: 8). ...
python
def default_vrf_max_paths(self, **kwargs): """Set BGP max paths property on default VRF address family. Args: rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. paths (str): Number of paths for BGP ECMP (default: 8). ...
[ "def", "default_vrf_max_paths", "(", "self", ",", "*", "*", "kwargs", ")", ":", "afi", "=", "kwargs", ".", "pop", "(", "'afi'", ",", "'ipv4'", ")", "callback", "=", "kwargs", ".", "pop", "(", "'callback'", ",", "self", ".", "_callback", ")", "get_confi...
Set BGP max paths property on default VRF address family. Args: rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. paths (str): Number of paths for BGP ECMP (default: 8). afi (str): Address family to configure. (ip...
[ "Set", "BGP", "max", "paths", "property", "on", "default", "VRF", "address", "family", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_0_0/bgp.py#L1334-L1403
54,727
miguelgrinberg/climax
climax.py
command
def command(*args, **kwargs): """Decorator to define a command. The arguments to this decorator are those of the `ArgumentParser <https://docs.python.org/3/library/argparse.html\ #argumentparser-objects>`_ object constructor. """ def decorator(f): if 'description' not in kwargs: ...
python
def command(*args, **kwargs): """Decorator to define a command. The arguments to this decorator are those of the `ArgumentParser <https://docs.python.org/3/library/argparse.html\ #argumentparser-objects>`_ object constructor. """ def decorator(f): if 'description' not in kwargs: ...
[ "def", "command", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "f", ")", ":", "if", "'description'", "not", "in", "kwargs", ":", "kwargs", "[", "'description'", "]", "=", "f", ".", "__doc__", "if", "'parents'", "in", ...
Decorator to define a command. The arguments to this decorator are those of the `ArgumentParser <https://docs.python.org/3/library/argparse.html\ #argumentparser-objects>`_ object constructor.
[ "Decorator", "to", "define", "a", "command", "." ]
57b72d2c3d3886f5dbc410e53ea3f26299fcc33e
https://github.com/miguelgrinberg/climax/blob/57b72d2c3d3886f5dbc410e53ea3f26299fcc33e/climax.py#L30-L59
54,728
miguelgrinberg/climax
climax.py
_subcommand
def _subcommand(group, *args, **kwargs): """Decorator to define a subcommand. This decorator is used for the group's @command decorator. """ def decorator(f): if 'help' not in kwargs: kwargs['help'] = f.__doc__ _parser_class = group._subparsers._parser_class if 'pars...
python
def _subcommand(group, *args, **kwargs): """Decorator to define a subcommand. This decorator is used for the group's @command decorator. """ def decorator(f): if 'help' not in kwargs: kwargs['help'] = f.__doc__ _parser_class = group._subparsers._parser_class if 'pars...
[ "def", "_subcommand", "(", "group", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "f", ")", ":", "if", "'help'", "not", "in", "kwargs", ":", "kwargs", "[", "'help'", "]", "=", "f", ".", "__doc__", "_parser_class", "=...
Decorator to define a subcommand. This decorator is used for the group's @command decorator.
[ "Decorator", "to", "define", "a", "subcommand", "." ]
57b72d2c3d3886f5dbc410e53ea3f26299fcc33e
https://github.com/miguelgrinberg/climax/blob/57b72d2c3d3886f5dbc410e53ea3f26299fcc33e/climax.py#L72-L100
54,729
miguelgrinberg/climax
climax.py
_subgroup
def _subgroup(group, *args, **kwargs): """Decorator to define a subgroup. This decorator is used for the group's @group decorator. """ def decorator(f): f.required = kwargs.pop('required', True) if 'parents' in kwargs: if not hasattr(f, '_argnames'): # pragma: no cover ...
python
def _subgroup(group, *args, **kwargs): """Decorator to define a subgroup. This decorator is used for the group's @group decorator. """ def decorator(f): f.required = kwargs.pop('required', True) if 'parents' in kwargs: if not hasattr(f, '_argnames'): # pragma: no cover ...
[ "def", "_subgroup", "(", "group", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "f", ")", ":", "f", ".", "required", "=", "kwargs", ".", "pop", "(", "'required'", ",", "True", ")", "if", "'parents'", "in", "kwargs", ...
Decorator to define a subgroup. This decorator is used for the group's @group decorator.
[ "Decorator", "to", "define", "a", "subgroup", "." ]
57b72d2c3d3886f5dbc410e53ea3f26299fcc33e
https://github.com/miguelgrinberg/climax/blob/57b72d2c3d3886f5dbc410e53ea3f26299fcc33e/climax.py#L103-L130
54,730
miguelgrinberg/climax
climax.py
group
def group(*args, **kwargs): """Decorator to define a command group. The arguments to this decorator are those of the `ArgumentParser <https://docs.python.org/3/library/argparse.html\ #argumentparser-objects>`_ object constructor. """ def decorator(f): f.required = kwargs.pop('required',...
python
def group(*args, **kwargs): """Decorator to define a command group. The arguments to this decorator are those of the `ArgumentParser <https://docs.python.org/3/library/argparse.html\ #argumentparser-objects>`_ object constructor. """ def decorator(f): f.required = kwargs.pop('required',...
[ "def", "group", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "f", ")", ":", "f", ".", "required", "=", "kwargs", ".", "pop", "(", "'required'", ",", "True", ")", "if", "'parents'", "in", "kwargs", ":", "if", "not"...
Decorator to define a command group. The arguments to this decorator are those of the `ArgumentParser <https://docs.python.org/3/library/argparse.html\ #argumentparser-objects>`_ object constructor.
[ "Decorator", "to", "define", "a", "command", "group", "." ]
57b72d2c3d3886f5dbc410e53ea3f26299fcc33e
https://github.com/miguelgrinberg/climax/blob/57b72d2c3d3886f5dbc410e53ea3f26299fcc33e/climax.py#L133-L197
54,731
miguelgrinberg/climax
climax.py
_get_dest
def _get_dest(*args, **kwargs): # pragma: no cover """ Duplicate argument names processing logic from argparse. argparse stores the variable in the namespace using the provided dest name, the first long option string, or the first short option string """ prefix_chars = kwargs.get('prefix_char...
python
def _get_dest(*args, **kwargs): # pragma: no cover """ Duplicate argument names processing logic from argparse. argparse stores the variable in the namespace using the provided dest name, the first long option string, or the first short option string """ prefix_chars = kwargs.get('prefix_char...
[ "def", "_get_dest", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# pragma: no cover", "prefix_chars", "=", "kwargs", ".", "get", "(", "'prefix_chars'", ",", "'-'", ")", "# determine short and long option strings", "option_strings", "=", "[", "]", "long_...
Duplicate argument names processing logic from argparse. argparse stores the variable in the namespace using the provided dest name, the first long option string, or the first short option string
[ "Duplicate", "argument", "names", "processing", "logic", "from", "argparse", "." ]
57b72d2c3d3886f5dbc410e53ea3f26299fcc33e
https://github.com/miguelgrinberg/climax/blob/57b72d2c3d3886f5dbc410e53ea3f26299fcc33e/climax.py#L200-L235
54,732
miguelgrinberg/climax
climax.py
argument
def argument(*args, **kwargs): """Decorator to define an argparse option or argument. The arguments to this decorator are the same as the `ArgumentParser.add_argument <https://docs.python.org/3/library/\ argparse.html#the-add-argument-method>`_ method. """ def decorator(f): if not hasat...
python
def argument(*args, **kwargs): """Decorator to define an argparse option or argument. The arguments to this decorator are the same as the `ArgumentParser.add_argument <https://docs.python.org/3/library/\ argparse.html#the-add-argument-method>`_ method. """ def decorator(f): if not hasat...
[ "def", "argument", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "f", ")", ":", "if", "not", "hasattr", "(", "f", ",", "'_arguments'", ")", ":", "f", ".", "_arguments", "=", "[", "]", "if", "not", "hasattr", "(", ...
Decorator to define an argparse option or argument. The arguments to this decorator are the same as the `ArgumentParser.add_argument <https://docs.python.org/3/library/\ argparse.html#the-add-argument-method>`_ method.
[ "Decorator", "to", "define", "an", "argparse", "option", "or", "argument", "." ]
57b72d2c3d3886f5dbc410e53ea3f26299fcc33e
https://github.com/miguelgrinberg/climax/blob/57b72d2c3d3886f5dbc410e53ea3f26299fcc33e/climax.py#L238-L254
54,733
475Cumulus/TBone
examples/chatrooms/backend/resources.py
EntryResource.create
async def create(self, **kwargs): ''' Override the create method to add the user's id to the request data ''' return await super(EntryResource, self).create(user=self.request['user'])
python
async def create(self, **kwargs): ''' Override the create method to add the user's id to the request data ''' return await super(EntryResource, self).create(user=self.request['user'])
[ "async", "def", "create", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "await", "super", "(", "EntryResource", ",", "self", ")", ".", "create", "(", "user", "=", "self", ".", "request", "[", "'user'", "]", ")" ]
Override the create method to add the user's id to the request data
[ "Override", "the", "create", "method", "to", "add", "the", "user", "s", "id", "to", "the", "request", "data" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/examples/chatrooms/backend/resources.py#L50-L52
54,734
475Cumulus/TBone
tbone/dispatch/channels/mongo.py
MongoChannel.consume_events
async def consume_events(self): ''' begin listening to messages that were entered after starting''' # begin by making sure the channel is created await self.create_channel() # get cursor method def create_cursor(): now = datetime.datetime.utcnow() dummy_id...
python
async def consume_events(self): ''' begin listening to messages that were entered after starting''' # begin by making sure the channel is created await self.create_channel() # get cursor method def create_cursor(): now = datetime.datetime.utcnow() dummy_id...
[ "async", "def", "consume_events", "(", "self", ")", ":", "# begin by making sure the channel is created", "await", "self", ".", "create_channel", "(", ")", "# get cursor method", "def", "create_cursor", "(", ")", ":", "now", "=", "datetime", ".", "datetime", ".", ...
begin listening to messages that were entered after starting
[ "begin", "listening", "to", "messages", "that", "were", "entered", "after", "starting" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/dispatch/channels/mongo.py#L59-L81
54,735
kratsg/ironman
ironman/__init__.py
engage
def engage(proto='udp'): ''' Fire thrusters. ''' from ironman.server import ServerFactory from twisted.internet import reactor from twisted.internet.defer import Deferred getattr(reactor, 'listen{0:s}'.format(proto.upper()))(8888, ServerFactory(proto, Deferred)) reactor.run()
python
def engage(proto='udp'): ''' Fire thrusters. ''' from ironman.server import ServerFactory from twisted.internet import reactor from twisted.internet.defer import Deferred getattr(reactor, 'listen{0:s}'.format(proto.upper()))(8888, ServerFactory(proto, Deferred)) reactor.run()
[ "def", "engage", "(", "proto", "=", "'udp'", ")", ":", "from", "ironman", ".", "server", "import", "ServerFactory", "from", "twisted", ".", "internet", "import", "reactor", "from", "twisted", ".", "internet", ".", "defer", "import", "Deferred", "getattr", "(...
Fire thrusters.
[ "Fire", "thrusters", "." ]
7d67b79970870e7e5520181d2afa3f423e46eb3a
https://github.com/kratsg/ironman/blob/7d67b79970870e7e5520181d2afa3f423e46eb3a/ironman/__init__.py#L10-L17
54,736
475Cumulus/TBone
examples/chatrooms/backend/models.py
Room.add_member
async def add_member(self, db, user): ''' Adds a new user to the list of room members, if memeber doesn't exist already ''' # use model's pk as query query = {self.primary_key: self.pk} # push review result = await db[self.get_collection_name()].update_one( filter=qu...
python
async def add_member(self, db, user): ''' Adds a new user to the list of room members, if memeber doesn't exist already ''' # use model's pk as query query = {self.primary_key: self.pk} # push review result = await db[self.get_collection_name()].update_one( filter=qu...
[ "async", "def", "add_member", "(", "self", ",", "db", ",", "user", ")", ":", "# use model's pk as query", "query", "=", "{", "self", ".", "primary_key", ":", "self", ".", "pk", "}", "# push review", "result", "=", "await", "db", "[", "self", ".", "get_co...
Adds a new user to the list of room members, if memeber doesn't exist already
[ "Adds", "a", "new", "user", "to", "the", "list", "of", "room", "members", "if", "memeber", "doesn", "t", "exist", "already" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/examples/chatrooms/backend/models.py#L72-L82
54,737
475Cumulus/TBone
tbone/db/models.py
create_collection
async def create_collection(db, model_class: MongoCollectionMixin): ''' Creates a MongoDB collection and all the declared indices in the model's ``Meta`` class :param db: A database handle :type db: motor.motor_asyncio.AsyncIOMotorClient :param model_class: The model to cre...
python
async def create_collection(db, model_class: MongoCollectionMixin): ''' Creates a MongoDB collection and all the declared indices in the model's ``Meta`` class :param db: A database handle :type db: motor.motor_asyncio.AsyncIOMotorClient :param model_class: The model to cre...
[ "async", "def", "create_collection", "(", "db", ",", "model_class", ":", "MongoCollectionMixin", ")", ":", "name", "=", "model_class", ".", "get_collection_name", "(", ")", "if", "name", ":", "try", ":", "# create collection", "coll", "=", "await", "db", ".", ...
Creates a MongoDB collection and all the declared indices in the model's ``Meta`` class :param db: A database handle :type db: motor.motor_asyncio.AsyncIOMotorClient :param model_class: The model to create :type model_class: Subclass of ``Model`` mixed with ``MongoColle...
[ "Creates", "a", "MongoDB", "collection", "and", "all", "the", "declared", "indices", "in", "the", "model", "s", "Meta", "class" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/db/models.py#L336-L378
54,738
475Cumulus/TBone
tbone/db/models.py
create_app_collections
async def create_app_collections(db): ''' load all models in app and create collections in db with specified indices''' futures = [] for model_class in MongoCollectionMixin.__subclasses__(): if model_class._meta.concrete is True: futures.append(create_collection(db, model_class)) aw...
python
async def create_app_collections(db): ''' load all models in app and create collections in db with specified indices''' futures = [] for model_class in MongoCollectionMixin.__subclasses__(): if model_class._meta.concrete is True: futures.append(create_collection(db, model_class)) aw...
[ "async", "def", "create_app_collections", "(", "db", ")", ":", "futures", "=", "[", "]", "for", "model_class", "in", "MongoCollectionMixin", ".", "__subclasses__", "(", ")", ":", "if", "model_class", ".", "_meta", ".", "concrete", "is", "True", ":", "futures...
load all models in app and create collections in db with specified indices
[ "load", "all", "models", "in", "app", "and", "create", "collections", "in", "db", "with", "specified", "indices" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/db/models.py#L381-L388
54,739
475Cumulus/TBone
tbone/db/models.py
MongoCollectionMixin.delete_entries
async def delete_entries(cls, db, query): ''' Delete documents by given query. ''' query = cls.process_query(query) for i in cls.connection_retries(): try: result = await db[cls.get_collection_name()].delete_many(query) return result except...
python
async def delete_entries(cls, db, query): ''' Delete documents by given query. ''' query = cls.process_query(query) for i in cls.connection_retries(): try: result = await db[cls.get_collection_name()].delete_many(query) return result except...
[ "async", "def", "delete_entries", "(", "cls", ",", "db", ",", "query", ")", ":", "query", "=", "cls", ".", "process_query", "(", "query", ")", "for", "i", "in", "cls", ".", "connection_retries", "(", ")", ":", "try", ":", "result", "=", "await", "db"...
Delete documents by given query.
[ "Delete", "documents", "by", "given", "query", "." ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/db/models.py#L141-L151
54,740
475Cumulus/TBone
tbone/db/models.py
MongoCollectionMixin.prepare_data
def prepare_data(self, data=None): ''' Prepare data for persistency by exporting it to native form and making sure we're not persisting with a null primary key. ''' data = data or self.export_data(native=True) # make sure we don't persist a null _id and let MongoDB auto-...
python
def prepare_data(self, data=None): ''' Prepare data for persistency by exporting it to native form and making sure we're not persisting with a null primary key. ''' data = data or self.export_data(native=True) # make sure we don't persist a null _id and let MongoDB auto-...
[ "def", "prepare_data", "(", "self", ",", "data", "=", "None", ")", ":", "data", "=", "data", "or", "self", ".", "export_data", "(", "native", "=", "True", ")", "# make sure we don't persist a null _id and let MongoDB auto-generate it", "if", "'_id'", "in", "data",...
Prepare data for persistency by exporting it to native form and making sure we're not persisting with a null primary key.
[ "Prepare", "data", "for", "persistency", "by", "exporting", "it", "to", "native", "form", "and", "making", "sure", "we", "re", "not", "persisting", "with", "a", "null", "primary", "key", "." ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/db/models.py#L179-L188
54,741
475Cumulus/TBone
tbone/db/models.py
MongoCollectionMixin.save
async def save(self, db=None): ''' If object has _id, then object will be created or fully rewritten. If not, object will be inserted and _id will be assigned. ''' self._db = db or self.db data = self.prepare_data() # validate object self.validate() ...
python
async def save(self, db=None): ''' If object has _id, then object will be created or fully rewritten. If not, object will be inserted and _id will be assigned. ''' self._db = db or self.db data = self.prepare_data() # validate object self.validate() ...
[ "async", "def", "save", "(", "self", ",", "db", "=", "None", ")", ":", "self", ".", "_db", "=", "db", "or", "self", ".", "db", "data", "=", "self", ".", "prepare_data", "(", ")", "# validate object", "self", ".", "validate", "(", ")", "# connect to D...
If object has _id, then object will be created or fully rewritten. If not, object will be inserted and _id will be assigned.
[ "If", "object", "has", "_id", "then", "object", "will", "be", "created", "or", "fully", "rewritten", ".", "If", "not", "object", "will", "be", "inserted", "and", "_id", "will", "be", "assigned", "." ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/db/models.py#L190-L216
54,742
475Cumulus/TBone
tbone/db/models.py
MongoCollectionMixin.update
async def update(self, db=None, data=None): ''' Update the entire document by replacing its content with new data, retaining its primary key ''' db = db or self.db if data: # update model explicitely with a new data structure # merge the current model's data with the...
python
async def update(self, db=None, data=None): ''' Update the entire document by replacing its content with new data, retaining its primary key ''' db = db or self.db if data: # update model explicitely with a new data structure # merge the current model's data with the...
[ "async", "def", "update", "(", "self", ",", "db", "=", "None", ",", "data", "=", "None", ")", ":", "db", "=", "db", "or", "self", ".", "db", "if", "data", ":", "# update model explicitely with a new data structure", "# merge the current model's data with the new d...
Update the entire document by replacing its content with new data, retaining its primary key
[ "Update", "the", "entire", "document", "by", "replacing", "its", "content", "with", "new", "data", "retaining", "its", "primary", "key" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/db/models.py#L245-L285
54,743
475Cumulus/TBone
tbone/db/models.py
MongoCollectionMixin.modify
async def modify(cls, db, key, data: dict): ''' Partially modify a document by providing a subset of its data fields to be modified :param db: Handle to the MongoDB database :param key: The primary key of the database object being modified. Usually its ``_id`` ...
python
async def modify(cls, db, key, data: dict): ''' Partially modify a document by providing a subset of its data fields to be modified :param db: Handle to the MongoDB database :param key: The primary key of the database object being modified. Usually its ``_id`` ...
[ "async", "def", "modify", "(", "cls", ",", "db", ",", "key", ",", "data", ":", "dict", ")", ":", "if", "data", "is", "None", ":", "raise", "BadRequest", "(", "'Failed to modify document. No data fields to modify'", ")", "# validate partial data", "cls", ".", "...
Partially modify a document by providing a subset of its data fields to be modified :param db: Handle to the MongoDB database :param key: The primary key of the database object being modified. Usually its ``_id`` :param data: The data set to be modified ...
[ "Partially", "modify", "a", "document", "by", "providing", "a", "subset", "of", "its", "data", "fields", "to", "be", "modified" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/db/models.py#L288-L333
54,744
475Cumulus/TBone
tbone/utils.py
run_once
def run_once(func): ''' Decorator for making sure a method can only be executed once ''' def wrapper(*args, **kwargs): if not wrapper.has_run: wrapper.has_run = True return func(*args, **kwargs) wrapper.has_run = False return wrapper
python
def run_once(func): ''' Decorator for making sure a method can only be executed once ''' def wrapper(*args, **kwargs): if not wrapper.has_run: wrapper.has_run = True return func(*args, **kwargs) wrapper.has_run = False return wrapper
[ "def", "run_once", "(", "func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "wrapper", ".", "has_run", ":", "wrapper", ".", "has_run", "=", "True", "return", "func", "(", "*", "args", ",", "*", "*...
Decorator for making sure a method can only be executed once
[ "Decorator", "for", "making", "sure", "a", "method", "can", "only", "be", "executed", "once" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/utils.py#L28-L35
54,745
brocade/pynos
pynos/versions/base/firmware.py
Firmware.download
def download(self, protocol, host, user, password, file_name, rbridge='all'): """ Download firmware to device """ urn = "{urn:brocade.com:mgmt:brocade-firmware}" request_fwdl = self.get_firmware_download_request(protocol, host, ...
python
def download(self, protocol, host, user, password, file_name, rbridge='all'): """ Download firmware to device """ urn = "{urn:brocade.com:mgmt:brocade-firmware}" request_fwdl = self.get_firmware_download_request(protocol, host, ...
[ "def", "download", "(", "self", ",", "protocol", ",", "host", ",", "user", ",", "password", ",", "file_name", ",", "rbridge", "=", "'all'", ")", ":", "urn", "=", "\"{urn:brocade.com:mgmt:brocade-firmware}\"", "request_fwdl", "=", "self", ".", "get_firmware_downl...
Download firmware to device
[ "Download", "firmware", "to", "device" ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/firmware.py#L41-L56
54,746
475Cumulus/TBone
tbone/resources/routers.py
Router.register
def register(self, resource, endpoint): ''' This methods registers a resource with the router and connects all receivers to their respective signals :param resource: The resource class to register :type resource: A subclass of ``Resource`` class :param en...
python
def register(self, resource, endpoint): ''' This methods registers a resource with the router and connects all receivers to their respective signals :param resource: The resource class to register :type resource: A subclass of ``Resource`` class :param en...
[ "def", "register", "(", "self", ",", "resource", ",", "endpoint", ")", ":", "if", "not", "issubclass", "(", "resource", ",", "Resource", ")", ":", "raise", "ValueError", "(", "'Not and instance of ``Resource`` subclass'", ")", "# register resource", "self", ".", ...
This methods registers a resource with the router and connects all receivers to their respective signals :param resource: The resource class to register :type resource: A subclass of ``Resource`` class :param endpoint: the name of the resource's endpoint as i...
[ "This", "methods", "registers", "a", "resource", "with", "the", "router", "and", "connects", "all", "receivers", "to", "their", "respective", "signals" ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/routers.py#L57-L75
54,747
475Cumulus/TBone
tbone/resources/routers.py
Router.urls_old
def urls_old(self, protocol=Resource.Protocol.http): ''' Iterate through all resources registered with this router and create a list endpoint and a detail endpoint for each one. Uses the router name as prefix and endpoint name of the resource when registered, to assemble the url pattern....
python
def urls_old(self, protocol=Resource.Protocol.http): ''' Iterate through all resources registered with this router and create a list endpoint and a detail endpoint for each one. Uses the router name as prefix and endpoint name of the resource when registered, to assemble the url pattern....
[ "def", "urls_old", "(", "self", ",", "protocol", "=", "Resource", ".", "Protocol", ".", "http", ")", ":", "url_patterns", "=", "[", "]", "for", "endpoint", ",", "resource_class", "in", "self", ".", "_registry", ".", "items", "(", ")", ":", "setattr", "...
Iterate through all resources registered with this router and create a list endpoint and a detail endpoint for each one. Uses the router name as prefix and endpoint name of the resource when registered, to assemble the url pattern. Uses the constructor-passed url method or class for generating u...
[ "Iterate", "through", "all", "resources", "registered", "with", "this", "router", "and", "create", "a", "list", "endpoint", "and", "a", "detail", "endpoint", "for", "each", "one", ".", "Uses", "the", "router", "name", "as", "prefix", "and", "endpoint", "name...
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/routers.py#L84-L116
54,748
475Cumulus/TBone
tbone/resources/routers.py
Router.dispatch
async def dispatch(self, app, payload): ''' Dispatches an incoming request and passes it to the relevant resource returning the response. :param app: Application handler. must be passed as part of the request :param payload: The request payload, contains...
python
async def dispatch(self, app, payload): ''' Dispatches an incoming request and passes it to the relevant resource returning the response. :param app: Application handler. must be passed as part of the request :param payload: The request payload, contains...
[ "async", "def", "dispatch", "(", "self", ",", "app", ",", "payload", ")", ":", "handler", "=", "None", "params", "=", "{", "}", "# parse request url, separating query params if any", "url", "=", "urlparse", "(", "payload", "[", "'href'", "]", ")", "path", "=...
Dispatches an incoming request and passes it to the relevant resource returning the response. :param app: Application handler. must be passed as part of the request :param payload: The request payload, contains all the parameters of the request
[ "Dispatches", "an", "incoming", "request", "and", "passes", "it", "to", "the", "relevant", "resource", "returning", "the", "response", "." ]
5a6672d8bbac449a0ab9e99560609f671fe84d4d
https://github.com/475Cumulus/TBone/blob/5a6672d8bbac449a0ab9e99560609f671fe84d4d/tbone/resources/routers.py#L205-L242
54,749
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/vcenter.py
Vcenter.add_vcenter
def add_vcenter(self, **kwargs): """ Add vCenter on the switch Args: id(str) : Name of an established vCenter url (bool) : vCenter URL username (str): Username of the vCenter password (str): Password of the vCenter callback (function):...
python
def add_vcenter(self, **kwargs): """ Add vCenter on the switch Args: id(str) : Name of an established vCenter url (bool) : vCenter URL username (str): Username of the vCenter password (str): Password of the vCenter callback (function):...
[ "def", "add_vcenter", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "vcenter", "=", "ET", ".", "SubElement", "(", "config", ",", "\"vcenter\"", ",", "xmlns", "=", "\"urn:brocade.com:mgmt:brocad...
Add vCenter on the switch Args: id(str) : Name of an established vCenter url (bool) : vCenter URL username (str): Username of the vCenter password (str): Password of the vCenter callback (function): A function executed upon completion of the ...
[ "Add", "vCenter", "on", "the", "switch" ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/vcenter.py#L40-L77
54,750
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/vcenter.py
Vcenter.activate_vcenter
def activate_vcenter(self, **kwargs): """ Activate vCenter on the switch Args: name: (str) : Name of an established vCenter activate (bool) : Activates the vCenter if activate=True else deactivates it callback (function): A funct...
python
def activate_vcenter(self, **kwargs): """ Activate vCenter on the switch Args: name: (str) : Name of an established vCenter activate (bool) : Activates the vCenter if activate=True else deactivates it callback (function): A funct...
[ "def", "activate_vcenter", "(", "self", ",", "*", "*", "kwargs", ")", ":", "name", "=", "kwargs", ".", "pop", "(", "'name'", ")", "activate", "=", "kwargs", ".", "pop", "(", "'activate'", ",", "True", ")", "vcenter_args", "=", "dict", "(", "id", "=",...
Activate vCenter on the switch Args: name: (str) : Name of an established vCenter activate (bool) : Activates the vCenter if activate=True else deactivates it callback (function): A function executed upon completion of the metho...
[ "Activate", "vCenter", "on", "the", "switch" ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/vcenter.py#L79-L108
54,751
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/vcenter.py
Vcenter.get_vcenter
def get_vcenter(self, **kwargs): """ Get vCenter hosts on the switch Args: callback (function): A function executed upon completion of the method. Returns: Returns a list of vcenters Raises: None """ config =...
python
def get_vcenter(self, **kwargs): """ Get vCenter hosts on the switch Args: callback (function): A function executed upon completion of the method. Returns: Returns a list of vcenters Raises: None """ config =...
[ "def", "get_vcenter", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "urn", "=", "\"urn:brocade.com:mgmt:brocade-vswitch\"", "ET", ".", "SubElement", "(", "config", ",", "\"vcenter\"", ",", "xmlns...
Get vCenter hosts on the switch Args: callback (function): A function executed upon completion of the method. Returns: Returns a list of vcenters Raises: None
[ "Get", "vCenter", "hosts", "on", "the", "switch" ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/vcenter.py#L110-L141
54,752
viniciuschiele/flask-io
flask_io/actions.py
Action.perform_authentication
def perform_authentication(self): """ Perform authentication on the incoming request. """ if not self.authenticators: return request.user = None request.auth = None for authenticator in self.authenticators: auth_tuple = authenticator.aut...
python
def perform_authentication(self): """ Perform authentication on the incoming request. """ if not self.authenticators: return request.user = None request.auth = None for authenticator in self.authenticators: auth_tuple = authenticator.aut...
[ "def", "perform_authentication", "(", "self", ")", ":", "if", "not", "self", ".", "authenticators", ":", "return", "request", ".", "user", "=", "None", "request", ".", "auth", "=", "None", "for", "authenticator", "in", "self", ".", "authenticators", ":", "...
Perform authentication on the incoming request.
[ "Perform", "authentication", "on", "the", "incoming", "request", "." ]
4e559419b3d8e6859f83fa16557b00542d5f3aa7
https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/actions.py#L29-L46
54,753
CCareaga/scum
scum/main.py
MainGUI.register_palette
def register_palette(self): """Converts pygmets style to urwid palatte""" default = 'default' palette = list(self.palette) mapping = CONFIG['rgb_to_short'] for tok in self.style.styles.keys(): for t in tok.split()[::-1]: st = self.style.styles[t] ...
python
def register_palette(self): """Converts pygmets style to urwid palatte""" default = 'default' palette = list(self.palette) mapping = CONFIG['rgb_to_short'] for tok in self.style.styles.keys(): for t in tok.split()[::-1]: st = self.style.styles[t] ...
[ "def", "register_palette", "(", "self", ")", ":", "default", "=", "'default'", "palette", "=", "list", "(", "self", ".", "palette", ")", "mapping", "=", "CONFIG", "[", "'rgb_to_short'", "]", "for", "tok", "in", "self", ".", "style", ".", "styles", ".", ...
Converts pygmets style to urwid palatte
[ "Converts", "pygmets", "style", "to", "urwid", "palatte" ]
15c21ab32f590271d2d12c3573573d35630f51b0
https://github.com/CCareaga/scum/blob/15c21ab32f590271d2d12c3573573d35630f51b0/scum/main.py#L1134-L1161
54,754
kdeldycke/chessboard
chessboard/solver.py
Permutations.increment
def increment(self): """ Increment the last permutation we returned to the next. """ # Increment position from the deepest place of the tree first. for index in reversed(range(self.depth)): self.indexes[index] += 1 # We haven't reached the end of board, no need to adjust ...
python
def increment(self): """ Increment the last permutation we returned to the next. """ # Increment position from the deepest place of the tree first. for index in reversed(range(self.depth)): self.indexes[index] += 1 # We haven't reached the end of board, no need to adjust ...
[ "def", "increment", "(", "self", ")", ":", "# Increment position from the deepest place of the tree first.", "for", "index", "in", "reversed", "(", "range", "(", "self", ".", "depth", ")", ")", ":", "self", ".", "indexes", "[", "index", "]", "+=", "1", "# We h...
Increment the last permutation we returned to the next.
[ "Increment", "the", "last", "permutation", "we", "returned", "to", "the", "next", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/solver.py#L69-L89
54,755
kdeldycke/chessboard
chessboard/solver.py
Permutations.skip_branch
def skip_branch(self, level): """ Abandon the branch at the provided level and skip to the next. When we call out to skip to the next branch of the search space, we push sublevel pieces to the maximum positions of the board. So that the next time the permutation iterator is called, it c...
python
def skip_branch(self, level): """ Abandon the branch at the provided level and skip to the next. When we call out to skip to the next branch of the search space, we push sublevel pieces to the maximum positions of the board. So that the next time the permutation iterator is called, it c...
[ "def", "skip_branch", "(", "self", ",", "level", ")", ":", "for", "i", "in", "range", "(", "level", "+", "1", ",", "self", ".", "depth", ")", ":", "self", ".", "indexes", "[", "i", "]", "=", "self", ".", "range_size", "-", "1" ]
Abandon the branch at the provided level and skip to the next. When we call out to skip to the next branch of the search space, we push sublevel pieces to the maximum positions of the board. So that the next time the permutation iterator is called, it can produce the vector state of the...
[ "Abandon", "the", "branch", "at", "the", "provided", "level", "and", "skip", "to", "the", "next", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/solver.py#L110-L119
54,756
kdeldycke/chessboard
chessboard/solver.py
SolverContext.solve
def solve(self): """ Solve all possible positions of pieces within the context. Depth-first, tree-traversal of the product space. """ # Create a new, empty board. board = Board(self.length, self.height) # Iterate through all combinations of positions. permutatio...
python
def solve(self): """ Solve all possible positions of pieces within the context. Depth-first, tree-traversal of the product space. """ # Create a new, empty board. board = Board(self.length, self.height) # Iterate through all combinations of positions. permutatio...
[ "def", "solve", "(", "self", ")", ":", "# Create a new, empty board.", "board", "=", "Board", "(", "self", ".", "length", ",", "self", ".", "height", ")", "# Iterate through all combinations of positions.", "permutations", "=", "Permutations", "(", "self", ".", "p...
Solve all possible positions of pieces within the context. Depth-first, tree-traversal of the product space.
[ "Solve", "all", "possible", "positions", "of", "pieces", "within", "the", "context", "." ]
ac7a14dc7b6905701e3f6d4e01e8fe1869241bed
https://github.com/kdeldycke/chessboard/blob/ac7a14dc7b6905701e3f6d4e01e8fe1869241bed/chessboard/solver.py#L160-L189
54,757
CCareaga/scum
scum/modules/browse.py
get_flagged_names
def get_flagged_names(): """Return a list of all filenames marked as flagged.""" l = [] for w in _widget_cache.values(): if w.flagged: l.append(w.get_node().get_value()) return l
python
def get_flagged_names(): """Return a list of all filenames marked as flagged.""" l = [] for w in _widget_cache.values(): if w.flagged: l.append(w.get_node().get_value()) return l
[ "def", "get_flagged_names", "(", ")", ":", "l", "=", "[", "]", "for", "w", "in", "_widget_cache", ".", "values", "(", ")", ":", "if", "w", ".", "flagged", ":", "l", ".", "append", "(", "w", ".", "get_node", "(", ")", ".", "get_value", "(", ")", ...
Return a list of all filenames marked as flagged.
[ "Return", "a", "list", "of", "all", "filenames", "marked", "as", "flagged", "." ]
15c21ab32f590271d2d12c3573573d35630f51b0
https://github.com/CCareaga/scum/blob/15c21ab32f590271d2d12c3573573d35630f51b0/scum/modules/browse.py#L239-L246
54,758
CCareaga/scum
scum/modules/browse.py
starts_expanded
def starts_expanded(name): """Return True if directory is a parent of initial cwd.""" if name is '/': return True l = name.split(dir_sep()) if len(l) > len(_initial_cwd): return False if l != _initial_cwd[:len(l)]: return False return True
python
def starts_expanded(name): """Return True if directory is a parent of initial cwd.""" if name is '/': return True l = name.split(dir_sep()) if len(l) > len(_initial_cwd): return False if l != _initial_cwd[:len(l)]: return False return True
[ "def", "starts_expanded", "(", "name", ")", ":", "if", "name", "is", "'/'", ":", "return", "True", "l", "=", "name", ".", "split", "(", "dir_sep", "(", ")", ")", "if", "len", "(", "l", ")", ">", "len", "(", "_initial_cwd", ")", ":", "return", "Fa...
Return True if directory is a parent of initial cwd.
[ "Return", "True", "if", "directory", "is", "a", "parent", "of", "initial", "cwd", "." ]
15c21ab32f590271d2d12c3573573d35630f51b0
https://github.com/CCareaga/scum/blob/15c21ab32f590271d2d12c3573573d35630f51b0/scum/modules/browse.py#L260-L273
54,759
CCareaga/scum
scum/modules/browse.py
escape_filename_sh
def escape_filename_sh(name): """Return a hopefully safe shell-escaped version of a filename.""" # check whether we have unprintable characters for ch in name: if ord(ch) < 32: # found one so use the ansi-c escaping return escape_filename_sh_ansic(name) # all printable ...
python
def escape_filename_sh(name): """Return a hopefully safe shell-escaped version of a filename.""" # check whether we have unprintable characters for ch in name: if ord(ch) < 32: # found one so use the ansi-c escaping return escape_filename_sh_ansic(name) # all printable ...
[ "def", "escape_filename_sh", "(", "name", ")", ":", "# check whether we have unprintable characters", "for", "ch", "in", "name", ":", "if", "ord", "(", "ch", ")", "<", "32", ":", "# found one so use the ansi-c escaping", "return", "escape_filename_sh_ansic", "(", "nam...
Return a hopefully safe shell-escaped version of a filename.
[ "Return", "a", "hopefully", "safe", "shell", "-", "escaped", "version", "of", "a", "filename", "." ]
15c21ab32f590271d2d12c3573573d35630f51b0
https://github.com/CCareaga/scum/blob/15c21ab32f590271d2d12c3573573d35630f51b0/scum/modules/browse.py#L276-L290
54,760
CCareaga/scum
scum/modules/browse.py
escape_filename_sh_ansic
def escape_filename_sh_ansic(name): """Return an ansi-c shell-escaped version of a filename.""" out =[] # gather the escaped characters into a list for ch in name: if ord(ch) < 32: out.append("\\x%02x"% ord(ch)) elif ch == '\\': out.append('\\\\') else: ...
python
def escape_filename_sh_ansic(name): """Return an ansi-c shell-escaped version of a filename.""" out =[] # gather the escaped characters into a list for ch in name: if ord(ch) < 32: out.append("\\x%02x"% ord(ch)) elif ch == '\\': out.append('\\\\') else: ...
[ "def", "escape_filename_sh_ansic", "(", "name", ")", ":", "out", "=", "[", "]", "# gather the escaped characters into a list", "for", "ch", "in", "name", ":", "if", "ord", "(", "ch", ")", "<", "32", ":", "out", ".", "append", "(", "\"\\\\x%02x\"", "%", "or...
Return an ansi-c shell-escaped version of a filename.
[ "Return", "an", "ansi", "-", "c", "shell", "-", "escaped", "version", "of", "a", "filename", "." ]
15c21ab32f590271d2d12c3573573d35630f51b0
https://github.com/CCareaga/scum/blob/15c21ab32f590271d2d12c3573573d35630f51b0/scum/modules/browse.py#L293-L307
54,761
CCareaga/scum
scum/modules/browse.py
FlagFileWidget.keypress
def keypress(self, size, key): """allow subclasses to intercept keystrokes""" key = self.__super.keypress(size, key) if key: key = self.unhandled_keys(size, key) return key
python
def keypress(self, size, key): """allow subclasses to intercept keystrokes""" key = self.__super.keypress(size, key) if key: key = self.unhandled_keys(size, key) return key
[ "def", "keypress", "(", "self", ",", "size", ",", "key", ")", ":", "key", "=", "self", ".", "__super", ".", "keypress", "(", "size", ",", "key", ")", "if", "key", ":", "key", "=", "self", ".", "unhandled_keys", "(", "size", ",", "key", ")", "retu...
allow subclasses to intercept keystrokes
[ "allow", "subclasses", "to", "intercept", "keystrokes" ]
15c21ab32f590271d2d12c3573573d35630f51b0
https://github.com/CCareaga/scum/blob/15c21ab32f590271d2d12c3573573d35630f51b0/scum/modules/browse.py#L58-L63
54,762
CCareaga/scum
scum/modules/browse.py
FlagFileWidget.update_w
def update_w(self): """Update the attributes of self.widget based on self.flagged. """ if self.flagged: self._w.attr = 'flagged' self._w.focus_attr = 'flagged focus' else: self._w.attr = 'body' self._w.focus_attr = 'focus'
python
def update_w(self): """Update the attributes of self.widget based on self.flagged. """ if self.flagged: self._w.attr = 'flagged' self._w.focus_attr = 'flagged focus' else: self._w.attr = 'body' self._w.focus_attr = 'focus'
[ "def", "update_w", "(", "self", ")", ":", "if", "self", ".", "flagged", ":", "self", ".", "_w", ".", "attr", "=", "'flagged'", "self", ".", "_w", ".", "focus_attr", "=", "'flagged focus'", "else", ":", "self", ".", "_w", ".", "attr", "=", "'body'", ...
Update the attributes of self.widget based on self.flagged.
[ "Update", "the", "attributes", "of", "self", ".", "widget", "based", "on", "self", ".", "flagged", "." ]
15c21ab32f590271d2d12c3573573d35630f51b0
https://github.com/CCareaga/scum/blob/15c21ab32f590271d2d12c3573573d35630f51b0/scum/modules/browse.py#L81-L89
54,763
CCareaga/scum
scum/modules/browse.py
DirectoryNode.load_child_node
def load_child_node(self, key): """Return either a FileNode or DirectoryNode""" index = self.get_child_index(key) if key is None: return EmptyNode(None) else: path = os.path.join(self.get_value(), key) if index < self.dir_count: return ...
python
def load_child_node(self, key): """Return either a FileNode or DirectoryNode""" index = self.get_child_index(key) if key is None: return EmptyNode(None) else: path = os.path.join(self.get_value(), key) if index < self.dir_count: return ...
[ "def", "load_child_node", "(", "self", ",", "key", ")", ":", "index", "=", "self", ".", "get_child_index", "(", "key", ")", "if", "key", "is", "None", ":", "return", "EmptyNode", "(", "None", ")", "else", ":", "path", "=", "os", ".", "path", ".", "...
Return either a FileNode or DirectoryNode
[ "Return", "either", "a", "FileNode", "or", "DirectoryNode" ]
15c21ab32f590271d2d12c3573573d35630f51b0
https://github.com/CCareaga/scum/blob/15c21ab32f590271d2d12c3573573d35630f51b0/scum/modules/browse.py#L214-L225
54,764
bennylope/django-simple-auth
simple_auth/forms.py
PasswordForm.clean_password
def clean_password(self): """ Validates that the password is a current password """ user_pass = self.cleaned_data.get('password') matches = Password.objects.filter(password=user_pass) if not matches: raise forms.ValidationError("Your password does not match.")
python
def clean_password(self): """ Validates that the password is a current password """ user_pass = self.cleaned_data.get('password') matches = Password.objects.filter(password=user_pass) if not matches: raise forms.ValidationError("Your password does not match.")
[ "def", "clean_password", "(", "self", ")", ":", "user_pass", "=", "self", ".", "cleaned_data", ".", "get", "(", "'password'", ")", "matches", "=", "Password", ".", "objects", ".", "filter", "(", "password", "=", "user_pass", ")", "if", "not", "matches", ...
Validates that the password is a current password
[ "Validates", "that", "the", "password", "is", "a", "current", "password" ]
4b2acbc4bb4d0a958895235ca36b9c371853bc6e
https://github.com/bennylope/django-simple-auth/blob/4b2acbc4bb4d0a958895235ca36b9c371853bc6e/simple_auth/forms.py#L22-L29
54,765
stewart/gfm
gfm.py
gfm
def gfm(text): """Processes Markdown according to GitHub Flavored Markdown spec.""" extractions = {} def extract_pre_block(matchobj): match = matchobj.group(0) hashed_match = hashlib.md5(match.encode('utf-8')).hexdigest() extractions[hashed_match] = match result = "{gfm-extr...
python
def gfm(text): """Processes Markdown according to GitHub Flavored Markdown spec.""" extractions = {} def extract_pre_block(matchobj): match = matchobj.group(0) hashed_match = hashlib.md5(match.encode('utf-8')).hexdigest() extractions[hashed_match] = match result = "{gfm-extr...
[ "def", "gfm", "(", "text", ")", ":", "extractions", "=", "{", "}", "def", "extract_pre_block", "(", "matchobj", ")", ":", "match", "=", "matchobj", ".", "group", "(", "0", ")", "hashed_match", "=", "hashlib", ".", "md5", "(", "match", ".", "encode", ...
Processes Markdown according to GitHub Flavored Markdown spec.
[ "Processes", "Markdown", "according", "to", "GitHub", "Flavored", "Markdown", "spec", "." ]
e14b082c62da03dcb57a15856282c4c6f93bb4d4
https://github.com/stewart/gfm/blob/e14b082c62da03dcb57a15856282c4c6f93bb4d4/gfm.py#L4-L40
54,766
stewart/gfm
gfm.py
markdown
def markdown(text): """Processes GFM then converts it to HTML.""" text = gfm(text) text = markdown_lib.markdown(text) return text
python
def markdown(text): """Processes GFM then converts it to HTML.""" text = gfm(text) text = markdown_lib.markdown(text) return text
[ "def", "markdown", "(", "text", ")", ":", "text", "=", "gfm", "(", "text", ")", "text", "=", "markdown_lib", ".", "markdown", "(", "text", ")", "return", "text" ]
Processes GFM then converts it to HTML.
[ "Processes", "GFM", "then", "converts", "it", "to", "HTML", "." ]
e14b082c62da03dcb57a15856282c4c6f93bb4d4
https://github.com/stewart/gfm/blob/e14b082c62da03dcb57a15856282c4c6f93bb4d4/gfm.py#L42-L46
54,767
lepture/terminal
terminal/builtin.py
Command.add_log_options
def add_log_options(self, verbose_func=None, quiet_func=None): """ A helper for setting up log options """ if not verbose_func: def verbose_func(): return log.config(verbose=True) if not quiet_func: def quiet_func(): retur...
python
def add_log_options(self, verbose_func=None, quiet_func=None): """ A helper for setting up log options """ if not verbose_func: def verbose_func(): return log.config(verbose=True) if not quiet_func: def quiet_func(): retur...
[ "def", "add_log_options", "(", "self", ",", "verbose_func", "=", "None", ",", "quiet_func", "=", "None", ")", ":", "if", "not", "verbose_func", ":", "def", "verbose_func", "(", ")", ":", "return", "log", ".", "config", "(", "verbose", "=", "True", ")", ...
A helper for setting up log options
[ "A", "helper", "for", "setting", "up", "log", "options" ]
5226d1cac53077f12624aa51f64de7b5b05d9cb8
https://github.com/lepture/terminal/blob/5226d1cac53077f12624aa51f64de7b5b05d9cb8/terminal/builtin.py#L44-L59
54,768
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/bgp.py
BGP.redistribute
def redistribute(self, **kwargs): """Set BGP redistribute properties. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. source (str): Source for redistributin...
python
def redistribute(self, **kwargs): """Set BGP redistribute properties. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. source (str): Source for redistributin...
[ "def", "redistribute", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# This method is the same as the base method except for one place.", "# The class doesn't inherit from the base class, though, so we have", "# to duplicate.", "source", "=", "kwargs", ".", "pop", "(", "'sou...
Set BGP redistribute properties. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. source (str): Source for redistributing. (connected) afi (str): Address...
[ "Set", "BGP", "redistribute", "properties", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/bgp.py#L477-L537
54,769
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/bgp.py
BGP._redistribute_builder
def _redistribute_builder(self, afi='ipv4', source=None): """Build BGP redistribute method. Do not use this method directly. You probably want ``redistribute``. Args: source (str): Source for redistributing. (connected) afi (str): Address family to configure. (ipv4, ip...
python
def _redistribute_builder(self, afi='ipv4', source=None): """Build BGP redistribute method. Do not use this method directly. You probably want ``redistribute``. Args: source (str): Source for redistributing. (connected) afi (str): Address family to configure. (ipv4, ip...
[ "def", "_redistribute_builder", "(", "self", ",", "afi", "=", "'ipv4'", ",", "source", "=", "None", ")", ":", "if", "source", "==", "'connected'", ":", "return", "getattr", "(", "self", ".", "_rbridge", ",", "'rbridge_id_router_router_bgp_address_family_{0}_'", ...
Build BGP redistribute method. Do not use this method directly. You probably want ``redistribute``. Args: source (str): Source for redistributing. (connected) afi (str): Address family to configure. (ipv4, ipv6) Returns: Method to redistribute desired sour...
[ "Build", "BGP", "redistribute", "method", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/bgp.py#L539-L574
54,770
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/bgp.py
BGP.max_paths
def max_paths(self, **kwargs): """Set BGP max paths property. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. paths (str): Number of paths for BGP ECMP (def...
python
def max_paths(self, **kwargs): """Set BGP max paths property. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. paths (str): Number of paths for BGP ECMP (def...
[ "def", "max_paths", "(", "self", ",", "*", "*", "kwargs", ")", ":", "afi", "=", "kwargs", ".", "pop", "(", "'afi'", ",", "'ipv4'", ")", "callback", "=", "kwargs", ".", "pop", "(", "'callback'", ",", "self", ".", "_callback", ")", "if", "afi", "not"...
Set BGP max paths property. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. paths (str): Number of paths for BGP ECMP (default: 8). afi (str): Address f...
[ "Set", "BGP", "max", "paths", "property", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/bgp.py#L576-L634
54,771
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/bgp.py
BGP._multihop_xml
def _multihop_xml(self, **kwargs): """Build BGP multihop XML. Do not use this method directly. You probably want ``multihop``. Args: rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. neighbor (ipaddress.ip_i...
python
def _multihop_xml(self, **kwargs): """Build BGP multihop XML. Do not use this method directly. You probably want ``multihop``. Args: rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. neighbor (ipaddress.ip_i...
[ "def", "_multihop_xml", "(", "self", ",", "*", "*", "kwargs", ")", ":", "ip_addr", "=", "kwargs", ".", "pop", "(", "'neighbor'", ")", "ip", "=", "str", "(", "ip_addr", ".", "ip", ")", "rbr_ns", "=", "'urn:brocade.com:mgmt:brocade-rbridge'", "bgp_ns", "=", ...
Build BGP multihop XML. Do not use this method directly. You probably want ``multihop``. Args: rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. neighbor (ipaddress.ip_interface): `ip_interface` object containing ...
[ "Build", "BGP", "multihop", "XML", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/bgp.py#L749-L801
54,772
brocade/pynos
pynos/utilities.py
return_xml
def return_xml(element_tree): """Return an XML Element. Args: element_tree (Element): XML Element to be returned. If sent as a ``str``, this function will attempt to convert it to an ``Element``. Returns: Element: An XML Element. Ra...
python
def return_xml(element_tree): """Return an XML Element. Args: element_tree (Element): XML Element to be returned. If sent as a ``str``, this function will attempt to convert it to an ``Element``. Returns: Element: An XML Element. Ra...
[ "def", "return_xml", "(", "element_tree", ")", ":", "if", "isinstance", "(", "element_tree", ",", "ET", ".", "Element", ")", ":", "return", "element_tree", "try", ":", "return", "ET", ".", "fromstring", "(", "element_tree", ")", "except", "TypeError", ":", ...
Return an XML Element. Args: element_tree (Element): XML Element to be returned. If sent as a ``str``, this function will attempt to convert it to an ``Element``. Returns: Element: An XML Element. Raises: TypeError: if `elem...
[ "Return", "an", "XML", "Element", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/utilities.py#L23-L58
54,773
brocade/pynos
pynos/utilities.py
valid_vlan_id
def valid_vlan_id(vlan_id, extended=True): """Validates a VLAN ID. Args: vlan_id (integer): VLAN ID to validate. If passed as ``str``, it will be cast to ``int``. extended (bool): If the VLAN ID range should be considered extended for Virtual Fabrics. Returns: ...
python
def valid_vlan_id(vlan_id, extended=True): """Validates a VLAN ID. Args: vlan_id (integer): VLAN ID to validate. If passed as ``str``, it will be cast to ``int``. extended (bool): If the VLAN ID range should be considered extended for Virtual Fabrics. Returns: ...
[ "def", "valid_vlan_id", "(", "vlan_id", ",", "extended", "=", "True", ")", ":", "minimum_vlan_id", "=", "1", "maximum_vlan_id", "=", "4095", "if", "extended", ":", "maximum_vlan_id", "=", "8191", "return", "minimum_vlan_id", "<=", "int", "(", "vlan_id", ")", ...
Validates a VLAN ID. Args: vlan_id (integer): VLAN ID to validate. If passed as ``str``, it will be cast to ``int``. extended (bool): If the VLAN ID range should be considered extended for Virtual Fabrics. Returns: bool: ``True`` if it is a valid VLAN ID. ``Fa...
[ "Validates", "a", "VLAN", "ID", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/utilities.py#L88-L119
54,774
brocade/pynos
pynos/utilities.py
merge_xml
def merge_xml(first_doc, second_doc): """Merges two XML documents. Args: first_doc (str): First XML document. `second_doc` is merged into this document. second_doc (str): Second XML document. It is merged into the first. Returns: XML Document: The merged document. ...
python
def merge_xml(first_doc, second_doc): """Merges two XML documents. Args: first_doc (str): First XML document. `second_doc` is merged into this document. second_doc (str): Second XML document. It is merged into the first. Returns: XML Document: The merged document. ...
[ "def", "merge_xml", "(", "first_doc", ",", "second_doc", ")", ":", "# Adapted from:", "# http://stackoverflow.com/questions/27258013/merge-two-xml-files-python", "# Maps each elements tag to the element from the first document", "if", "isinstance", "(", "first_doc", ",", "lxml", "....
Merges two XML documents. Args: first_doc (str): First XML document. `second_doc` is merged into this document. second_doc (str): Second XML document. It is merged into the first. Returns: XML Document: The merged document. Raises: None Example: ...
[ "Merges", "two", "XML", "documents", "." ]
bd8a34e98f322de3fc06750827d8bbc3a0c00380
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/utilities.py#L196-L246
54,775
rsenk330/pylibsass
pylibsass/events.py
FileSystemEvents.get_scss_files
def get_scss_files(self, skip_partials=True, with_source_path=False): """Gets all SCSS files in the source directory. :param bool skip_partials: If True, partials will be ignored. Otherwise, all SCSS files, including ones that begin ...
python
def get_scss_files(self, skip_partials=True, with_source_path=False): """Gets all SCSS files in the source directory. :param bool skip_partials: If True, partials will be ignored. Otherwise, all SCSS files, including ones that begin ...
[ "def", "get_scss_files", "(", "self", ",", "skip_partials", "=", "True", ",", "with_source_path", "=", "False", ")", ":", "scss_files", "=", "[", "]", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "self", ".", "_source_path", ...
Gets all SCSS files in the source directory. :param bool skip_partials: If True, partials will be ignored. Otherwise, all SCSS files, including ones that begin with '_' will be returned. :param boom with_source_path: If true, the `so...
[ "Gets", "all", "SCSS", "files", "in", "the", "source", "directory", "." ]
f029490db8e4c2178c9564efeeace95bbf8cceff
https://github.com/rsenk330/pylibsass/blob/f029490db8e4c2178c9564efeeace95bbf8cceff/pylibsass/events.py#L17-L45
54,776
CivicSpleen/ambry
ambry/library/search_backends/postgres_backend.py
DatasetPostgreSQLIndex._index_document
def _index_document(self, document, force=False): """ Adds dataset document to the index. """ query = text(""" INSERT INTO dataset_index(vid, title, keywords, doc) VALUES(:vid, :title, string_to_array(:keywords, ' '), to_tsvector('english', :doc)); """) self.execu...
python
def _index_document(self, document, force=False): """ Adds dataset document to the index. """ query = text(""" INSERT INTO dataset_index(vid, title, keywords, doc) VALUES(:vid, :title, string_to_array(:keywords, ' '), to_tsvector('english', :doc)); """) self.execu...
[ "def", "_index_document", "(", "self", ",", "document", ",", "force", "=", "False", ")", ":", "query", "=", "text", "(", "\"\"\"\n INSERT INTO dataset_index(vid, title, keywords, doc)\n VALUES(:vid, :title, string_to_array(:keywords, ' '), to_tsvector('english',...
Adds dataset document to the index.
[ "Adds", "dataset", "document", "to", "the", "index", "." ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/postgres_backend.py#L233-L239
54,777
CivicSpleen/ambry
ambry/library/search_backends/postgres_backend.py
PartitionPostgreSQLIndex.is_indexed
def is_indexed(self, partition): """ Returns True if partition is already indexed. Otherwise returns False. """ query = text(""" SELECT vid FROM partition_index WHERE vid = :vid; """) result = self.execute(query, vid=partition.vid) return bool(...
python
def is_indexed(self, partition): """ Returns True if partition is already indexed. Otherwise returns False. """ query = text(""" SELECT vid FROM partition_index WHERE vid = :vid; """) result = self.execute(query, vid=partition.vid) return bool(...
[ "def", "is_indexed", "(", "self", ",", "partition", ")", ":", "query", "=", "text", "(", "\"\"\"\n SELECT vid\n FROM partition_index\n WHERE vid = :vid;\n \"\"\"", ")", "result", "=", "self", ".", "execute", "(", "query", ",", "vid"...
Returns True if partition is already indexed. Otherwise returns False.
[ "Returns", "True", "if", "partition", "is", "already", "indexed", ".", "Otherwise", "returns", "False", "." ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/postgres_backend.py#L515-L523
54,778
CivicSpleen/ambry
ambry/library/search_backends/postgres_backend.py
IdentifierPostgreSQLIndex.search
def search(self, search_phrase, limit=None): """ Finds identifiers by search phrase. Args: search_phrase (str or unicode): limit (int, optional): how many results to return. None means without limit. Returns: list of IdentifierSearchResult instances. ...
python
def search(self, search_phrase, limit=None): """ Finds identifiers by search phrase. Args: search_phrase (str or unicode): limit (int, optional): how many results to return. None means without limit. Returns: list of IdentifierSearchResult instances. ...
[ "def", "search", "(", "self", ",", "search_phrase", ",", "limit", "=", "None", ")", ":", "query_parts", "=", "[", "'SELECT identifier, type, name, similarity(name, :word) AS sml'", ",", "'FROM identifier_index'", ",", "'WHERE name % :word'", ",", "'ORDER BY sml DESC, name'"...
Finds identifiers by search phrase. Args: search_phrase (str or unicode): limit (int, optional): how many results to return. None means without limit. Returns: list of IdentifierSearchResult instances.
[ "Finds", "identifiers", "by", "search", "phrase", "." ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/library/search_backends/postgres_backend.py#L547-L584
54,779
SmartTeleMax/iktomi
iktomi/utils/text.py
pare
def pare(text, size, etc='...'): '''Pare text to have maximum size and add etc to the end if it's changed''' size = int(size) text = text.strip() if len(text)>size: # strip the last word or not to_be_stripped = not whitespace_re.findall(text[size-1:size+2]) text = text[:size...
python
def pare(text, size, etc='...'): '''Pare text to have maximum size and add etc to the end if it's changed''' size = int(size) text = text.strip() if len(text)>size: # strip the last word or not to_be_stripped = not whitespace_re.findall(text[size-1:size+2]) text = text[:size...
[ "def", "pare", "(", "text", ",", "size", ",", "etc", "=", "'...'", ")", ":", "size", "=", "int", "(", "size", ")", "text", "=", "text", ".", "strip", "(", ")", "if", "len", "(", "text", ")", ">", "size", ":", "# strip the last word or not", "to_be_...
Pare text to have maximum size and add etc to the end if it's changed
[ "Pare", "text", "to", "have", "maximum", "size", "and", "add", "etc", "to", "the", "end", "if", "it", "s", "changed" ]
80bc0f1408d63efe7f5844367d1f6efba44b35f2
https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/utils/text.py#L6-L27
54,780
project-ncl/pnc-cli
pnc_cli/environments.py
get_environment
def get_environment(id=None, name=None): """ Get a specific Environment by name or ID """ data = get_environment_raw(id, name) if data: return utils.format_json(data)
python
def get_environment(id=None, name=None): """ Get a specific Environment by name or ID """ data = get_environment_raw(id, name) if data: return utils.format_json(data)
[ "def", "get_environment", "(", "id", "=", "None", ",", "name", "=", "None", ")", ":", "data", "=", "get_environment_raw", "(", "id", ",", "name", ")", "if", "data", ":", "return", "utils", ".", "format_json", "(", "data", ")" ]
Get a specific Environment by name or ID
[ "Get", "a", "specific", "Environment", "by", "name", "or", "ID" ]
3dc149bf84928f60a8044ac50b58bbaddd451902
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/environments.py#L18-L24
54,781
project-ncl/pnc-cli
pnc_cli/environments.py
list_environments_raw
def list_environments_raw(page_size=200, page_index=0, sort="", q=""): """ List all Environments """ response = utils.checked_api_call(pnc_api.environments, 'get_all', page_size=page_size, page_index=page_index, sort=sort, q=q) if response: return response.content
python
def list_environments_raw(page_size=200, page_index=0, sort="", q=""): """ List all Environments """ response = utils.checked_api_call(pnc_api.environments, 'get_all', page_size=page_size, page_index=page_index, sort=sort, q=q) if response: return response.content
[ "def", "list_environments_raw", "(", "page_size", "=", "200", ",", "page_index", "=", "0", ",", "sort", "=", "\"\"", ",", "q", "=", "\"\"", ")", ":", "response", "=", "utils", ".", "checked_api_call", "(", "pnc_api", ".", "environments", ",", "'get_all'", ...
List all Environments
[ "List", "all", "Environments" ]
3dc149bf84928f60a8044ac50b58bbaddd451902
https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/environments.py#L43-L49
54,782
CivicSpleen/ambry
ambry/orm/table.py
Table.primary_dimensions
def primary_dimensions(self): """Iterate over the primary dimension columns, columns which do not have a parent """ from ambry.valuetype.core import ROLE for c in self.columns: if not c.parent and c.role == ROLE.DIMENSION: yield c
python
def primary_dimensions(self): """Iterate over the primary dimension columns, columns which do not have a parent """ from ambry.valuetype.core import ROLE for c in self.columns: if not c.parent and c.role == ROLE.DIMENSION: yield c
[ "def", "primary_dimensions", "(", "self", ")", ":", "from", "ambry", ".", "valuetype", ".", "core", "import", "ROLE", "for", "c", "in", "self", ".", "columns", ":", "if", "not", "c", ".", "parent", "and", "c", ".", "role", "==", "ROLE", ".", "DIMENSI...
Iterate over the primary dimension columns, columns which do not have a parent
[ "Iterate", "over", "the", "primary", "dimension", "columns", "columns", "which", "do", "not", "have", "a", "parent" ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/table.py#L94-L103
54,783
CivicSpleen/ambry
ambry/orm/table.py
Table.primary_measures
def primary_measures(self): """Iterate over the primary columns, columns which do not have a parent Also sets the property partition_stats to the stats collection for the partition and column. """ from ambry.valuetype.core import ROLE for c in self.columns: if not ...
python
def primary_measures(self): """Iterate over the primary columns, columns which do not have a parent Also sets the property partition_stats to the stats collection for the partition and column. """ from ambry.valuetype.core import ROLE for c in self.columns: if not ...
[ "def", "primary_measures", "(", "self", ")", ":", "from", "ambry", ".", "valuetype", ".", "core", "import", "ROLE", "for", "c", "in", "self", ".", "columns", ":", "if", "not", "c", ".", "parent", "and", "c", ".", "role", "==", "ROLE", ".", "MEASURE",...
Iterate over the primary columns, columns which do not have a parent Also sets the property partition_stats to the stats collection for the partition and column.
[ "Iterate", "over", "the", "primary", "columns", "columns", "which", "do", "not", "have", "a", "parent" ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/table.py#L106-L116
54,784
CivicSpleen/ambry
ambry/orm/table.py
Table.is_empty
def is_empty(self): """Return True if the table has no columns or the only column is the id""" if len(self.columns) == 0: return True if len(self.columns) == 1 and self.columns[0].name == 'id': return True return False
python
def is_empty(self): """Return True if the table has no columns or the only column is the id""" if len(self.columns) == 0: return True if len(self.columns) == 1 and self.columns[0].name == 'id': return True return False
[ "def", "is_empty", "(", "self", ")", ":", "if", "len", "(", "self", ".", "columns", ")", "==", "0", ":", "return", "True", "if", "len", "(", "self", ".", "columns", ")", "==", "1", "and", "self", ".", "columns", "[", "0", "]", ".", "name", "=="...
Return True if the table has no columns or the only column is the id
[ "Return", "True", "if", "the", "table", "has", "no", "columns", "or", "the", "only", "column", "is", "the", "id" ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/table.py#L206-L214
54,785
CivicSpleen/ambry
ambry/orm/table.py
Table.update_from_stats
def update_from_stats(self, stats): """Update columns based on partition statistics""" sd = dict(stats) for c in self.columns: if c not in sd: continue stat = sd[c] if stat.size and stat.size > c.size: c.size = stat.size ...
python
def update_from_stats(self, stats): """Update columns based on partition statistics""" sd = dict(stats) for c in self.columns: if c not in sd: continue stat = sd[c] if stat.size and stat.size > c.size: c.size = stat.size ...
[ "def", "update_from_stats", "(", "self", ",", "stats", ")", ":", "sd", "=", "dict", "(", "stats", ")", "for", "c", "in", "self", ".", "columns", ":", "if", "c", "not", "in", "sd", ":", "continue", "stat", "=", "sd", "[", "c", "]", "if", "stat", ...
Update columns based on partition statistics
[ "Update", "columns", "based", "on", "partition", "statistics" ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/table.py#L251-L266
54,786
CivicSpleen/ambry
ambry/orm/table.py
Table.transforms
def transforms(self): """Return an array of arrays of column transforms. #The return value is an list of list, with each list being a segment of column transformations, and #each segment having one entry per column. """ tr = [] for c in self.columns: tr.app...
python
def transforms(self): """Return an array of arrays of column transforms. #The return value is an list of list, with each list being a segment of column transformations, and #each segment having one entry per column. """ tr = [] for c in self.columns: tr.app...
[ "def", "transforms", "(", "self", ")", ":", "tr", "=", "[", "]", "for", "c", "in", "self", ".", "columns", ":", "tr", ".", "append", "(", "c", ".", "expanded_transform", ")", "return", "six", ".", "moves", ".", "zip_longest", "(", "*", "tr", ")" ]
Return an array of arrays of column transforms. #The return value is an list of list, with each list being a segment of column transformations, and #each segment having one entry per column.
[ "Return", "an", "array", "of", "arrays", "of", "column", "transforms", "." ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/table.py#L288-L300
54,787
CivicSpleen/ambry
ambry/orm/table.py
Table.before_insert
def before_insert(mapper, conn, target): """event.listen method for Sqlalchemy to set the seqience_id for this object and create an ObjectNumber value for the id""" if target.sequence_id is None: from ambry.orm.exc import DatabaseError raise DatabaseError('Must have seque...
python
def before_insert(mapper, conn, target): """event.listen method for Sqlalchemy to set the seqience_id for this object and create an ObjectNumber value for the id""" if target.sequence_id is None: from ambry.orm.exc import DatabaseError raise DatabaseError('Must have seque...
[ "def", "before_insert", "(", "mapper", ",", "conn", ",", "target", ")", ":", "if", "target", ".", "sequence_id", "is", "None", ":", "from", "ambry", ".", "orm", ".", "exc", "import", "DatabaseError", "raise", "DatabaseError", "(", "'Must have sequence id befor...
event.listen method for Sqlalchemy to set the seqience_id for this object and create an ObjectNumber value for the id
[ "event", ".", "listen", "method", "for", "Sqlalchemy", "to", "set", "the", "seqience_id", "for", "this", "object", "and", "create", "an", "ObjectNumber", "value", "for", "the", "id" ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/table.py#L344-L351
54,788
CivicSpleen/ambry
ambry/orm/table.py
Table.before_update
def before_update(mapper, conn, target): """Set the Table ID based on the dataset number and the sequence number for the table.""" target.name = Table.mangle_name(target.name) if isinstance(target, Column): raise TypeError('Got a column instead of a table') target....
python
def before_update(mapper, conn, target): """Set the Table ID based on the dataset number and the sequence number for the table.""" target.name = Table.mangle_name(target.name) if isinstance(target, Column): raise TypeError('Got a column instead of a table') target....
[ "def", "before_update", "(", "mapper", ",", "conn", ",", "target", ")", ":", "target", ".", "name", "=", "Table", ".", "mangle_name", "(", "target", ".", "name", ")", "if", "isinstance", "(", "target", ",", "Column", ")", ":", "raise", "TypeError", "("...
Set the Table ID based on the dataset number and the sequence number for the table.
[ "Set", "the", "Table", "ID", "based", "on", "the", "dataset", "number", "and", "the", "sequence", "number", "for", "the", "table", "." ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/table.py#L354-L363
54,789
parkouss/rcontrol
rcontrol/core.py
SessionManager.wait_for_tasks
def wait_for_tasks(self, raise_if_error=True): """ Wait for the running tasks lauched from the sessions. Note that it also wait for tasks that are started from other tasks callbacks, like on_finished. :param raise_if_error: if True, raise all possible encountered er...
python
def wait_for_tasks(self, raise_if_error=True): """ Wait for the running tasks lauched from the sessions. Note that it also wait for tasks that are started from other tasks callbacks, like on_finished. :param raise_if_error: if True, raise all possible encountered er...
[ "def", "wait_for_tasks", "(", "self", ",", "raise_if_error", "=", "True", ")", ":", "errors", "=", "[", "]", "tasks_seen", "=", "TaskCache", "(", ")", "while", "True", ":", "for", "session", "in", "self", ".", "values", "(", ")", ":", "errs", "=", "s...
Wait for the running tasks lauched from the sessions. Note that it also wait for tasks that are started from other tasks callbacks, like on_finished. :param raise_if_error: if True, raise all possible encountered errors using :class:`TaskErrors`. Else the errors are returned ...
[ "Wait", "for", "the", "running", "tasks", "lauched", "from", "the", "sessions", "." ]
1764c1492f00d3f1a57dabe09983ed369aade828
https://github.com/parkouss/rcontrol/blob/1764c1492f00d3f1a57dabe09983ed369aade828/rcontrol/core.py#L387-L414
54,790
parkouss/rcontrol
rcontrol/core.py
CommandTask.error
def error(self): """ Return an instance of Exception if any, else None. Actually check for a :class:`TimeoutError` or a :class:`ExitCodeError`. """ if self.__timed_out: return TimeoutError(self.session, self, "timeout") if self.__exit_code is not None...
python
def error(self): """ Return an instance of Exception if any, else None. Actually check for a :class:`TimeoutError` or a :class:`ExitCodeError`. """ if self.__timed_out: return TimeoutError(self.session, self, "timeout") if self.__exit_code is not None...
[ "def", "error", "(", "self", ")", ":", "if", "self", ".", "__timed_out", ":", "return", "TimeoutError", "(", "self", ".", "session", ",", "self", ",", "\"timeout\"", ")", "if", "self", ".", "__exit_code", "is", "not", "None", "and", "self", ".", "__exp...
Return an instance of Exception if any, else None. Actually check for a :class:`TimeoutError` or a :class:`ExitCodeError`.
[ "Return", "an", "instance", "of", "Exception", "if", "any", "else", "None", "." ]
1764c1492f00d3f1a57dabe09983ed369aade828
https://github.com/parkouss/rcontrol/blob/1764c1492f00d3f1a57dabe09983ed369aade828/rcontrol/core.py#L557-L570
54,791
CivicSpleen/ambry
ambry/orm/dataset.py
Dataset.incver
def incver(self): """Increment all of the version numbers""" d = {} for p in self.__mapper__.attrs: if p.key in ['vid','vname','fqname', 'version', 'cache_key']: continue if p.key == 'revision': d[p.key] = self.revision + 1 else...
python
def incver(self): """Increment all of the version numbers""" d = {} for p in self.__mapper__.attrs: if p.key in ['vid','vname','fqname', 'version', 'cache_key']: continue if p.key == 'revision': d[p.key] = self.revision + 1 else...
[ "def", "incver", "(", "self", ")", ":", "d", "=", "{", "}", "for", "p", "in", "self", ".", "__mapper__", ".", "attrs", ":", "if", "p", ".", "key", "in", "[", "'vid'", ",", "'vname'", ",", "'fqname'", ",", "'version'", ",", "'cache_key'", "]", ":"...
Increment all of the version numbers
[ "Increment", "all", "of", "the", "version", "numbers" ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/dataset.py#L118-L131
54,792
CivicSpleen/ambry
ambry/orm/dataset.py
Dataset.new_unique_object
def new_unique_object(self, table_class, sequence_id=None, force_query=False, **kwargs): """Use next_sequence_id to create a new child of the dataset, with a unique id""" from sqlalchemy.exc import IntegrityError from sqlalchemy.orm.exc import FlushError # If a sequence ID was specified...
python
def new_unique_object(self, table_class, sequence_id=None, force_query=False, **kwargs): """Use next_sequence_id to create a new child of the dataset, with a unique id""" from sqlalchemy.exc import IntegrityError from sqlalchemy.orm.exc import FlushError # If a sequence ID was specified...
[ "def", "new_unique_object", "(", "self", ",", "table_class", ",", "sequence_id", "=", "None", ",", "force_query", "=", "False", ",", "*", "*", "kwargs", ")", ":", "from", "sqlalchemy", ".", "exc", "import", "IntegrityError", "from", "sqlalchemy", ".", "orm",...
Use next_sequence_id to create a new child of the dataset, with a unique id
[ "Use", "next_sequence_id", "to", "create", "a", "new", "child", "of", "the", "dataset", "with", "a", "unique", "id" ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/dataset.py#L182-L259
54,793
CivicSpleen/ambry
ambry/orm/dataset.py
Dataset.new_table
def new_table(self, name, add_id=True, **kwargs): '''Add a table to the schema, or update it it already exists. If updating, will only update data. ''' from . import Table from .exc import NotFoundError try: table = self.table(name) extant = True...
python
def new_table(self, name, add_id=True, **kwargs): '''Add a table to the schema, or update it it already exists. If updating, will only update data. ''' from . import Table from .exc import NotFoundError try: table = self.table(name) extant = True...
[ "def", "new_table", "(", "self", ",", "name", ",", "add_id", "=", "True", ",", "*", "*", "kwargs", ")", ":", "from", ".", "import", "Table", "from", ".", "exc", "import", "NotFoundError", "try", ":", "table", "=", "self", ".", "table", "(", "name", ...
Add a table to the schema, or update it it already exists. If updating, will only update data.
[ "Add", "a", "table", "to", "the", "schema", "or", "update", "it", "it", "already", "exists", "." ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/dataset.py#L273-L312
54,794
CivicSpleen/ambry
ambry/orm/dataset.py
Dataset.new_partition
def new_partition(self, table, **kwargs): """ Creates new partition and returns it. Args: table (orm.Table): Returns: orm.Partition """ from . import Partition # Create the basic partition record, with a sequence ID. if isinstance(tabl...
python
def new_partition(self, table, **kwargs): """ Creates new partition and returns it. Args: table (orm.Table): Returns: orm.Partition """ from . import Partition # Create the basic partition record, with a sequence ID. if isinstance(tabl...
[ "def", "new_partition", "(", "self", ",", "table", ",", "*", "*", "kwargs", ")", ":", "from", ".", "import", "Partition", "# Create the basic partition record, with a sequence ID.", "if", "isinstance", "(", "table", ",", "string_types", ")", ":", "table", "=", "...
Creates new partition and returns it. Args: table (orm.Table): Returns: orm.Partition
[ "Creates", "new", "partition", "and", "returns", "it", "." ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/dataset.py#L314-L349
54,795
CivicSpleen/ambry
ambry/orm/dataset.py
Dataset.partition
def partition(self, ref=None, **kwargs): """ Returns partition by ref. """ from .exc import NotFoundError from six import text_type if ref: for p in self.partitions: # This is slow for large datasets, like Census years. if (text_type(ref) == text_type(p.name...
python
def partition(self, ref=None, **kwargs): """ Returns partition by ref. """ from .exc import NotFoundError from six import text_type if ref: for p in self.partitions: # This is slow for large datasets, like Census years. if (text_type(ref) == text_type(p.name...
[ "def", "partition", "(", "self", ",", "ref", "=", "None", ",", "*", "*", "kwargs", ")", ":", "from", ".", "exc", "import", "NotFoundError", "from", "six", "import", "text_type", "if", "ref", ":", "for", "p", "in", "self", ".", "partitions", ":", "# T...
Returns partition by ref.
[ "Returns", "partition", "by", "ref", "." ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/dataset.py#L351-L369
54,796
CivicSpleen/ambry
ambry/orm/dataset.py
Dataset.bsfile
def bsfile(self, path): """Return a Build Source file ref, creating a new one if the one requested does not exist""" from sqlalchemy.orm.exc import NoResultFound from ambry.orm.exc import NotFoundError try: f = object_session(self)\ .query(File)\ ...
python
def bsfile(self, path): """Return a Build Source file ref, creating a new one if the one requested does not exist""" from sqlalchemy.orm.exc import NoResultFound from ambry.orm.exc import NotFoundError try: f = object_session(self)\ .query(File)\ ...
[ "def", "bsfile", "(", "self", ",", "path", ")", ":", "from", "sqlalchemy", ".", "orm", ".", "exc", "import", "NoResultFound", "from", "ambry", ".", "orm", ".", "exc", "import", "NotFoundError", "try", ":", "f", "=", "object_session", "(", "self", ")", ...
Return a Build Source file ref, creating a new one if the one requested does not exist
[ "Return", "a", "Build", "Source", "file", "ref", "creating", "a", "new", "one", "if", "the", "one", "requested", "does", "not", "exist" ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/dataset.py#L523-L540
54,797
CivicSpleen/ambry
ambry/orm/dataset.py
Dataset.row
def row(self, fields): """Return a row for fields, for CSV files, pretty printing, etc, give a set of fields to return""" d = self.dict row = [None] * len(fields) for i, f in enumerate(fields): if f in d: row[i] = d[f] return row
python
def row(self, fields): """Return a row for fields, for CSV files, pretty printing, etc, give a set of fields to return""" d = self.dict row = [None] * len(fields) for i, f in enumerate(fields): if f in d: row[i] = d[f] return row
[ "def", "row", "(", "self", ",", "fields", ")", ":", "d", "=", "self", ".", "dict", "row", "=", "[", "None", "]", "*", "len", "(", "fields", ")", "for", "i", ",", "f", "in", "enumerate", "(", "fields", ")", ":", "if", "f", "in", "d", ":", "r...
Return a row for fields, for CSV files, pretty printing, etc, give a set of fields to return
[ "Return", "a", "row", "for", "fields", "for", "CSV", "files", "pretty", "printing", "etc", "give", "a", "set", "of", "fields", "to", "return" ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/dataset.py#L595-L606
54,798
CivicSpleen/ambry
ambry/orm/dataset.py
ConfigAccessor.metadata
def metadata(self): """Access process configuarion values as attributes. """ from ambry.metadata.schema import Top # cross-module import top = Top() top.build_from_db(self.dataset) return top
python
def metadata(self): """Access process configuarion values as attributes. """ from ambry.metadata.schema import Top # cross-module import top = Top() top.build_from_db(self.dataset) return top
[ "def", "metadata", "(", "self", ")", ":", "from", "ambry", ".", "metadata", ".", "schema", "import", "Top", "# cross-module import", "top", "=", "Top", "(", ")", "top", ".", "build_from_db", "(", "self", ".", "dataset", ")", "return", "top" ]
Access process configuarion values as attributes.
[ "Access", "process", "configuarion", "values", "as", "attributes", "." ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/dataset.py#L626-L631
54,799
CivicSpleen/ambry
ambry/orm/dataset.py
ConfigAccessor.rows
def rows(self): """Return configuration in a form that can be used to reconstitute a Metadata object. Returns all of the rows for a dataset. This is distinct from get_config_value, which returns the value for the library. """ from ambry.orm import Config as SAConfig ...
python
def rows(self): """Return configuration in a form that can be used to reconstitute a Metadata object. Returns all of the rows for a dataset. This is distinct from get_config_value, which returns the value for the library. """ from ambry.orm import Config as SAConfig ...
[ "def", "rows", "(", "self", ")", ":", "from", "ambry", ".", "orm", "import", "Config", "as", "SAConfig", "from", "sqlalchemy", "import", "or_", "rows", "=", "[", "]", "configs", "=", "self", ".", "dataset", ".", "session", ".", "query", "(", "SAConfig"...
Return configuration in a form that can be used to reconstitute a Metadata object. Returns all of the rows for a dataset. This is distinct from get_config_value, which returns the value for the library.
[ "Return", "configuration", "in", "a", "form", "that", "can", "be", "used", "to", "reconstitute", "a", "Metadata", "object", ".", "Returns", "all", "of", "the", "rows", "for", "a", "dataset", "." ]
d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/dataset.py#L649-L680