repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
jelmer/python-fastimport
fastimport/processors/info_processor.py
_iterable_as_config_list
def _iterable_as_config_list(s): """Format an iterable as a sequence of comma-separated strings. To match what ConfigObj expects, a single item list has a trailing comma. """ items = sorted(s) if len(items) == 1: return "%s," % (items[0],) else: return ", ".join(items)
python
def _iterable_as_config_list(s): """Format an iterable as a sequence of comma-separated strings. To match what ConfigObj expects, a single item list has a trailing comma. """ items = sorted(s) if len(items) == 1: return "%s," % (items[0],) else: return ", ".join(items)
[ "def", "_iterable_as_config_list", "(", "s", ")", ":", "items", "=", "sorted", "(", "s", ")", "if", "len", "(", "items", ")", "==", "1", ":", "return", "\"%s,\"", "%", "(", "items", "[", "0", "]", ",", ")", "else", ":", "return", "\", \"", ".", "...
Format an iterable as a sequence of comma-separated strings. To match what ConfigObj expects, a single item list has a trailing comma.
[ "Format", "an", "iterable", "as", "a", "sequence", "of", "comma", "-", "separated", "strings", ".", "To", "match", "what", "ConfigObj", "expects", "a", "single", "item", "list", "has", "a", "trailing", "comma", "." ]
train
https://github.com/jelmer/python-fastimport/blob/5cef9e037b7d7b37f58f522ac9ea4e343e6a1dff/fastimport/processors/info_processor.py#L277-L286
jelmer/python-fastimport
fastimport/processors/info_processor.py
InfoProcessor._dump_stats_group
def _dump_stats_group(self, title, items, normal_formatter=None, verbose_formatter=None): """Dump a statistics group. In verbose mode, do so as a config file so that other processors can load the information if they want to. :param normal_formatter: the callable to apply...
python
def _dump_stats_group(self, title, items, normal_formatter=None, verbose_formatter=None): """Dump a statistics group. In verbose mode, do so as a config file so that other processors can load the information if they want to. :param normal_formatter: the callable to apply...
[ "def", "_dump_stats_group", "(", "self", ",", "title", ",", "items", ",", "normal_formatter", "=", "None", ",", "verbose_formatter", "=", "None", ")", ":", "if", "self", ".", "verbose", ":", "self", ".", "outf", ".", "write", "(", "\"[%s]\\n\"", "%", "("...
Dump a statistics group. In verbose mode, do so as a config file so that other processors can load the information if they want to. :param normal_formatter: the callable to apply to the value before displaying it in normal mode :param verbose_formatter: the callable to...
[ "Dump", "a", "statistics", "group", ".", "In", "verbose", "mode", "do", "so", "as", "a", "config", "file", "so", "that", "other", "processors", "can", "load", "the", "information", "if", "they", "want", "to", ".", ":", "param", "normal_formatter", ":", "...
train
https://github.com/jelmer/python-fastimport/blob/5cef9e037b7d7b37f58f522ac9ea4e343e6a1dff/fastimport/processors/info_processor.py#L144-L169
jelmer/python-fastimport
fastimport/processors/info_processor.py
InfoProcessor.blob_handler
def blob_handler(self, cmd): """Process a BlobCommand.""" self.cmd_counts[cmd.name] += 1 if cmd.mark is None: self.blobs['unmarked'].add(cmd.id) else: self.blobs['new'].add(cmd.id) # Marks can be re-used so remove it from used if already there. ...
python
def blob_handler(self, cmd): """Process a BlobCommand.""" self.cmd_counts[cmd.name] += 1 if cmd.mark is None: self.blobs['unmarked'].add(cmd.id) else: self.blobs['new'].add(cmd.id) # Marks can be re-used so remove it from used if already there. ...
[ "def", "blob_handler", "(", "self", ",", "cmd", ")", ":", "self", ".", "cmd_counts", "[", "cmd", ".", "name", "]", "+=", "1", "if", "cmd", ".", "mark", "is", "None", ":", "self", ".", "blobs", "[", "'unmarked'", "]", ".", "add", "(", "cmd", ".", ...
Process a BlobCommand.
[ "Process", "a", "BlobCommand", "." ]
train
https://github.com/jelmer/python-fastimport/blob/5cef9e037b7d7b37f58f522ac9ea4e343e6a1dff/fastimport/processors/info_processor.py#L175-L188
jelmer/python-fastimport
fastimport/processors/info_processor.py
InfoProcessor.commit_handler
def commit_handler(self, cmd): """Process a CommitCommand.""" self.cmd_counts[cmd.name] += 1 self.committers.add(cmd.committer) if cmd.author is not None: self.separate_authors_found = True for fc in cmd.iter_files(): self.file_cmd_counts[fc.name] += 1 ...
python
def commit_handler(self, cmd): """Process a CommitCommand.""" self.cmd_counts[cmd.name] += 1 self.committers.add(cmd.committer) if cmd.author is not None: self.separate_authors_found = True for fc in cmd.iter_files(): self.file_cmd_counts[fc.name] += 1 ...
[ "def", "commit_handler", "(", "self", ",", "cmd", ")", ":", "self", ".", "cmd_counts", "[", "cmd", ".", "name", "]", "+=", "1", "self", ".", "committers", ".", "add", "(", "cmd", ".", "committer", ")", "if", "cmd", ".", "author", "is", "not", "None...
Process a CommitCommand.
[ "Process", "a", "CommitCommand", "." ]
train
https://github.com/jelmer/python-fastimport/blob/5cef9e037b7d7b37f58f522ac9ea4e343e6a1dff/fastimport/processors/info_processor.py#L194-L236
jelmer/python-fastimport
fastimport/processors/info_processor.py
InfoProcessor.reset_handler
def reset_handler(self, cmd): """Process a ResetCommand.""" self.cmd_counts[cmd.name] += 1 if cmd.ref.startswith('refs/tags/'): self.lightweight_tags += 1 else: if cmd.from_ is not None: self.reftracker.track_heads_for_ref( cmd....
python
def reset_handler(self, cmd): """Process a ResetCommand.""" self.cmd_counts[cmd.name] += 1 if cmd.ref.startswith('refs/tags/'): self.lightweight_tags += 1 else: if cmd.from_ is not None: self.reftracker.track_heads_for_ref( cmd....
[ "def", "reset_handler", "(", "self", ",", "cmd", ")", ":", "self", ".", "cmd_counts", "[", "cmd", ".", "name", "]", "+=", "1", "if", "cmd", ".", "ref", ".", "startswith", "(", "'refs/tags/'", ")", ":", "self", ".", "lightweight_tags", "+=", "1", "els...
Process a ResetCommand.
[ "Process", "a", "ResetCommand", "." ]
train
https://github.com/jelmer/python-fastimport/blob/5cef9e037b7d7b37f58f522ac9ea4e343e6a1dff/fastimport/processors/info_processor.py#L238-L246
essanpupil/pygoogling
pygoogling/googling.py
GoogleSearch.start_search
def start_search(self, max_page=1): """method to start send query to google. Search start from page 1. max_page determine how many result expected hint: 10 result per page for google """ for page in range(1, (max_page + 1)): start = "start={0}".format(str((page - 1) ...
python
def start_search(self, max_page=1): """method to start send query to google. Search start from page 1. max_page determine how many result expected hint: 10 result per page for google """ for page in range(1, (max_page + 1)): start = "start={0}".format(str((page - 1) ...
[ "def", "start_search", "(", "self", ",", "max_page", "=", "1", ")", ":", "for", "page", "in", "range", "(", "1", ",", "(", "max_page", "+", "1", ")", ")", ":", "start", "=", "\"start={0}\"", ".", "format", "(", "str", "(", "(", "page", "-", "1", ...
method to start send query to google. Search start from page 1. max_page determine how many result expected hint: 10 result per page for google
[ "method", "to", "start", "send", "query", "to", "google", ".", "Search", "start", "from", "page", "1", "." ]
train
https://github.com/essanpupil/pygoogling/blob/29738dca48cc28b33913049b1bfc972211f16368/pygoogling/googling.py#L25-L35
essanpupil/pygoogling
pygoogling/googling.py
GoogleSearch.more_search
def more_search(self, more_page): """Method to add more result to an already exist result. more_page determine how many result page should be added to the current result. """ next_page = self.current_page + 1 top_page = more_page + self.current_page for page in r...
python
def more_search(self, more_page): """Method to add more result to an already exist result. more_page determine how many result page should be added to the current result. """ next_page = self.current_page + 1 top_page = more_page + self.current_page for page in r...
[ "def", "more_search", "(", "self", ",", "more_page", ")", ":", "next_page", "=", "self", ".", "current_page", "+", "1", "top_page", "=", "more_page", "+", "self", ".", "current_page", "for", "page", "in", "range", "(", "next_page", ",", "(", "top_page", ...
Method to add more result to an already exist result. more_page determine how many result page should be added to the current result.
[ "Method", "to", "add", "more", "result", "to", "an", "already", "exist", "result", "." ]
train
https://github.com/essanpupil/pygoogling/blob/29738dca48cc28b33913049b1bfc972211f16368/pygoogling/googling.py#L37-L49
essanpupil/pygoogling
pygoogling/googling.py
GoogleSearch._execute_search_request
def _execute_search_request(self, url): """method to execute the query to google. The specified page and keyword must already included in the url. """ try: self.request_page = requests.get(url) except requests.ConnectionError: print("Connection to...
python
def _execute_search_request(self, url): """method to execute the query to google. The specified page and keyword must already included in the url. """ try: self.request_page = requests.get(url) except requests.ConnectionError: print("Connection to...
[ "def", "_execute_search_request", "(", "self", ",", "url", ")", ":", "try", ":", "self", ".", "request_page", "=", "requests", ".", "get", "(", "url", ")", "except", "requests", ".", "ConnectionError", ":", "print", "(", "\"Connection to {0} failed\"", ".", ...
method to execute the query to google. The specified page and keyword must already included in the url.
[ "method", "to", "execute", "the", "query", "to", "google", "." ]
train
https://github.com/essanpupil/pygoogling/blob/29738dca48cc28b33913049b1bfc972211f16368/pygoogling/googling.py#L51-L89
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.readConfig
def readConfig(self, configuration): """Read configuration from dict. Read configuration from a JSON configuration file. :param configuration: configuration to load. :type configuration: dict. """ self.__logger.debug("Reading configuration") self.city = configur...
python
def readConfig(self, configuration): """Read configuration from dict. Read configuration from a JSON configuration file. :param configuration: configuration to load. :type configuration: dict. """ self.__logger.debug("Reading configuration") self.city = configur...
[ "def", "readConfig", "(", "self", ",", "configuration", ")", ":", "self", ".", "__logger", ".", "debug", "(", "\"Reading configuration\"", ")", "self", ".", "city", "=", "configuration", "[", "\"name\"", "]", "self", ".", "__logger", ".", "info", "(", "\"C...
Read configuration from dict. Read configuration from a JSON configuration file. :param configuration: configuration to load. :type configuration: dict.
[ "Read", "configuration", "from", "dict", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L113-L155
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.readConfigFromJSON
def readConfigFromJSON(self, fileName): """Read configuration from JSON. :param fileName: path to the configuration file. :type fileName: str. """ self.__logger.debug("readConfigFromJSON: reading from " + fileName) with open(fileName) as data_file: data = loa...
python
def readConfigFromJSON(self, fileName): """Read configuration from JSON. :param fileName: path to the configuration file. :type fileName: str. """ self.__logger.debug("readConfigFromJSON: reading from " + fileName) with open(fileName) as data_file: data = loa...
[ "def", "readConfigFromJSON", "(", "self", ",", "fileName", ")", ":", "self", ".", "__logger", ".", "debug", "(", "\"readConfigFromJSON: reading from \"", "+", "fileName", ")", "with", "open", "(", "fileName", ")", "as", "data_file", ":", "data", "=", "load", ...
Read configuration from JSON. :param fileName: path to the configuration file. :type fileName: str.
[ "Read", "configuration", "from", "JSON", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L157-L166
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.configToJson
def configToJson(self, fileName): """Save the configuration of the city in a JSON. :param fileName: path to the output file. :type fileName: str. """ config = self.getConfig() with open(fileName, "w") as outfile: dump(config, outfile, indent=4, sort_keys=True...
python
def configToJson(self, fileName): """Save the configuration of the city in a JSON. :param fileName: path to the output file. :type fileName: str. """ config = self.getConfig() with open(fileName, "w") as outfile: dump(config, outfile, indent=4, sort_keys=True...
[ "def", "configToJson", "(", "self", ",", "fileName", ")", ":", "config", "=", "self", ".", "getConfig", "(", ")", "with", "open", "(", "fileName", ",", "\"w\"", ")", "as", "outfile", ":", "dump", "(", "config", ",", "outfile", ",", "indent", "=", "4"...
Save the configuration of the city in a JSON. :param fileName: path to the output file. :type fileName: str.
[ "Save", "the", "configuration", "of", "the", "city", "in", "a", "JSON", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L168-L176
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.getConfig
def getConfig(self): """Return the configuration of the city. :return: configuration of the city. :rtype: dict. """ config = {} config["name"] = self.city config["intervals"] = self.__intervals config["last_date"] = self.__lastDay config["excluded...
python
def getConfig(self): """Return the configuration of the city. :return: configuration of the city. :rtype: dict. """ config = {} config["name"] = self.city config["intervals"] = self.__intervals config["last_date"] = self.__lastDay config["excluded...
[ "def", "getConfig", "(", "self", ")", ":", "config", "=", "{", "}", "config", "[", "\"name\"", "]", "=", "self", ".", "city", "config", "[", "\"intervals\"", "]", "=", "self", ".", "__intervals", "config", "[", "\"last_date\"", "]", "=", "self", ".", ...
Return the configuration of the city. :return: configuration of the city. :rtype: dict.
[ "Return", "the", "configuration", "of", "the", "city", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L178-L198
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.addFilter
def addFilter(self, field, value): """Add a filter to the seach. :param field: what field filter (see GitHub search). :type field: str. :param value: value of the filter (see GitHub search). :type value: str. """ if "<" not in value or ">" not in value or ".." no...
python
def addFilter(self, field, value): """Add a filter to the seach. :param field: what field filter (see GitHub search). :type field: str. :param value: value of the filter (see GitHub search). :type value: str. """ if "<" not in value or ">" not in value or ".." no...
[ "def", "addFilter", "(", "self", ",", "field", ",", "value", ")", ":", "if", "\"<\"", "not", "in", "value", "or", "\">\"", "not", "in", "value", "or", "\"..\"", "not", "in", "value", ":", "value", "=", "\":\"", "+", "value", "if", "self", ".", "__u...
Add a filter to the seach. :param field: what field filter (see GitHub search). :type field: str. :param value: value of the filter (see GitHub search). :type value: str.
[ "Add", "a", "filter", "to", "the", "seach", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L202-L216
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.__processUsers
def __processUsers(self): """Process users of the queue.""" while self.__usersToProccess.empty() and not self.__end: pass while not self.__end or not self.__usersToProccess.empty(): self.__lockGetUser.acquire() try: new_user = self.__usersToPr...
python
def __processUsers(self): """Process users of the queue.""" while self.__usersToProccess.empty() and not self.__end: pass while not self.__end or not self.__usersToProccess.empty(): self.__lockGetUser.acquire() try: new_user = self.__usersToPr...
[ "def", "__processUsers", "(", "self", ")", ":", "while", "self", ".", "__usersToProccess", ".", "empty", "(", ")", "and", "not", "self", ".", "__end", ":", "pass", "while", "not", "self", ".", "__end", "or", "not", "self", ".", "__usersToProccess", ".", ...
Process users of the queue.
[ "Process", "users", "of", "the", "queue", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L218-L235
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.__addUser
def __addUser(self, new_user): """Add new users to the list. :param new_user: name of a GitHub user to include in the ranking :type new_user: str. """ self.__lockReadAddUser.acquire() if new_user not in self.__cityUsers and \ new_user not in s...
python
def __addUser(self, new_user): """Add new users to the list. :param new_user: name of a GitHub user to include in the ranking :type new_user: str. """ self.__lockReadAddUser.acquire() if new_user not in self.__cityUsers and \ new_user not in s...
[ "def", "__addUser", "(", "self", ",", "new_user", ")", ":", "self", ".", "__lockReadAddUser", ".", "acquire", "(", ")", "if", "new_user", "not", "in", "self", ".", "__cityUsers", "and", "new_user", "not", "in", "self", ".", "__excludedUsers", ":", "self", ...
Add new users to the list. :param new_user: name of a GitHub user to include in the ranking :type new_user: str.
[ "Add", "new", "users", "to", "the", "list", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L237-L260
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.__getPeriodUsers
def __getPeriodUsers(self, start_date, final_date): """Get all the users given a period. :param start_date: start date of the range to search users :type start_date: time.date. :param final_date: final date of the range to search users :type final_date: t...
python
def __getPeriodUsers(self, start_date, final_date): """Get all the users given a period. :param start_date: start date of the range to search users :type start_date: time.date. :param final_date: final date of the range to search users :type final_date: t...
[ "def", "__getPeriodUsers", "(", "self", ",", "start_date", ",", "final_date", ")", ":", "self", ".", "__logger", ".", "info", "(", "\"Getting users from \"", "+", "start_date", "+", "\" to \"", "+", "final_date", ")", "url", "=", "self", ".", "__getURL", "("...
Get all the users given a period. :param start_date: start date of the range to search users :type start_date: time.date. :param final_date: final date of the range to search users :type final_date: time.date.
[ "Get", "all", "the", "users", "given", "a", "period", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L262-L293
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.getCityUsers
def getCityUsers(self, numberOfThreads=20): """Get all the users from the city. :param numberOfThreads: number of threads to run. :type numberOfThreads: int. """ if not self.__intervals: self.__logger.debug("Calculating best intervals") self.calculateBest...
python
def getCityUsers(self, numberOfThreads=20): """Get all the users from the city. :param numberOfThreads: number of threads to run. :type numberOfThreads: int. """ if not self.__intervals: self.__logger.debug("Calculating best intervals") self.calculateBest...
[ "def", "getCityUsers", "(", "self", ",", "numberOfThreads", "=", "20", ")", ":", "if", "not", "self", ".", "__intervals", ":", "self", ".", "__logger", ".", "debug", "(", "\"Calculating best intervals\"", ")", "self", ".", "calculateBestIntervals", "(", ")", ...
Get all the users from the city. :param numberOfThreads: number of threads to run. :type numberOfThreads: int.
[ "Get", "all", "the", "users", "from", "the", "city", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L295-L320
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.calculateBestIntervals
def calculateBestIntervals(self): """Calcule valid intervals of a city.""" self.__intervals = [] self.__readAPI(self.__getURL()) today = datetime.datetime.now().date() self.__validInterval(datetime.date(2008, 1, 1), today) self.__logger.info("Total number of intervals: "...
python
def calculateBestIntervals(self): """Calcule valid intervals of a city.""" self.__intervals = [] self.__readAPI(self.__getURL()) today = datetime.datetime.now().date() self.__validInterval(datetime.date(2008, 1, 1), today) self.__logger.info("Total number of intervals: "...
[ "def", "calculateBestIntervals", "(", "self", ")", ":", "self", ".", "__intervals", "=", "[", "]", "self", ".", "__readAPI", "(", "self", ".", "__getURL", "(", ")", ")", "today", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "date", "(...
Calcule valid intervals of a city.
[ "Calcule", "valid", "intervals", "of", "a", "city", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L324-L333
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.__validInterval
def __validInterval(self, start, finish): """Check if the interval is correct. An interval is correct if it has less than 1001 users. If the interval is correct, it will be added to '_intervals' attribute. Else, interval will be split in two news intervals and these intervals ...
python
def __validInterval(self, start, finish): """Check if the interval is correct. An interval is correct if it has less than 1001 users. If the interval is correct, it will be added to '_intervals' attribute. Else, interval will be split in two news intervals and these intervals ...
[ "def", "__validInterval", "(", "self", ",", "start", ",", "finish", ")", ":", "url", "=", "self", ".", "__getURL", "(", "1", ",", "start", ".", "strftime", "(", "\"%Y-%m-%d\"", ")", ",", "finish", ".", "strftime", "(", "\"%Y-%m-%d\"", ")", ")", "data",...
Check if the interval is correct. An interval is correct if it has less than 1001 users. If the interval is correct, it will be added to '_intervals' attribute. Else, interval will be split in two news intervals and these intervals will be checked. :param start: start d...
[ "Check", "if", "the", "interval", "is", "correct", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L335-L365
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.export
def export(self, template_file_name, output_file_name, sort="public", data=None, limit=0): """Export ranking to a file. Args: template_file_name (str): where is the template (moustache template) output_file_name (str): where create the file with th...
python
def export(self, template_file_name, output_file_name, sort="public", data=None, limit=0): """Export ranking to a file. Args: template_file_name (str): where is the template (moustache template) output_file_name (str): where create the file with th...
[ "def", "export", "(", "self", ",", "template_file_name", ",", "output_file_name", ",", "sort", "=", "\"public\"", ",", "data", "=", "None", ",", "limit", "=", "0", ")", ":", "exportedData", "=", "{", "}", "exportedUsers", "=", "self", ".", "__exportUsers",...
Export ranking to a file. Args: template_file_name (str): where is the template (moustache template) output_file_name (str): where create the file with the ranking sort (str): field to sort the users
[ "Export", "ranking", "to", "a", "file", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L369-L394
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.getSortedUsers
def getSortedUsers(self, order="public"): """Return a list with sorted users. :param order: the field to sort the users. - contributions (total number of contributions) - public (public contributions) - private (private contributions) - name -...
python
def getSortedUsers(self, order="public"): """Return a list with sorted users. :param order: the field to sort the users. - contributions (total number of contributions) - public (public contributions) - private (private contributions) - name -...
[ "def", "getSortedUsers", "(", "self", ",", "order", "=", "\"public\"", ")", ":", "try", ":", "self", ".", "__processedUsers", ".", "sort", "(", "key", "=", "lambda", "u", ":", "getattr", "(", "u", ",", "order", ")", ",", "reverse", "=", "True", ")", ...
Return a list with sorted users. :param order: the field to sort the users. - contributions (total number of contributions) - public (public contributions) - private (private contributions) - name - followers - join - organizat...
[ "Return", "a", "list", "with", "sorted", "users", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L396-L416
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.__exportUsers
def __exportUsers(self, sort, limit=0): """Export the users to a dictionary. :param sort: field to sort the users :type sort: str. :return: exported users. :rtype: dict. """ position = 1 dataUsers = self.getSortedUsers(sort) if limit: ...
python
def __exportUsers(self, sort, limit=0): """Export the users to a dictionary. :param sort: field to sort the users :type sort: str. :return: exported users. :rtype: dict. """ position = 1 dataUsers = self.getSortedUsers(sort) if limit: ...
[ "def", "__exportUsers", "(", "self", ",", "sort", ",", "limit", "=", "0", ")", ":", "position", "=", "1", "dataUsers", "=", "self", ".", "getSortedUsers", "(", "sort", ")", "if", "limit", ":", "dataUsers", "=", "dataUsers", "[", ":", "limit", "]", "e...
Export the users to a dictionary. :param sort: field to sort the users :type sort: str. :return: exported users. :rtype: dict.
[ "Export", "the", "users", "to", "a", "dictionary", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L418-L443
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.calculeToday
def calculeToday(self): """Calcule the intervals from the last date.""" self.__logger.debug("Add today") last = datetime.datetime.strptime(self.__lastDay, "%Y-%m-%d") today = datetime.datetime.now().date() self.__validInterval(last, today)
python
def calculeToday(self): """Calcule the intervals from the last date.""" self.__logger.debug("Add today") last = datetime.datetime.strptime(self.__lastDay, "%Y-%m-%d") today = datetime.datetime.now().date() self.__validInterval(last, today)
[ "def", "calculeToday", "(", "self", ")", ":", "self", ".", "__logger", ".", "debug", "(", "\"Add today\"", ")", "last", "=", "datetime", ".", "datetime", ".", "strptime", "(", "self", ".", "__lastDay", ",", "\"%Y-%m-%d\"", ")", "today", "=", "datetime", ...
Calcule the intervals from the last date.
[ "Calcule", "the", "intervals", "from", "the", "last", "date", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L448-L453
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.__addLocationsToURL
def __addLocationsToURL(self, locations): """Format all locations to GitHub's URL API. :param locations: locations where to search users. :type locations: list(str). """ for l in self.__locations: self.__urlLocations += "+location:\""\ + str(quote(l)) + ...
python
def __addLocationsToURL(self, locations): """Format all locations to GitHub's URL API. :param locations: locations where to search users. :type locations: list(str). """ for l in self.__locations: self.__urlLocations += "+location:\""\ + str(quote(l)) + ...
[ "def", "__addLocationsToURL", "(", "self", ",", "locations", ")", ":", "for", "l", "in", "self", ".", "__locations", ":", "self", ".", "__urlLocations", "+=", "\"+location:\\\"\"", "+", "str", "(", "quote", "(", "l", ")", ")", "+", "\"\\\"\"" ]
Format all locations to GitHub's URL API. :param locations: locations where to search users. :type locations: list(str).
[ "Format", "all", "locations", "to", "GitHub", "s", "URL", "API", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L455-L463
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.__launchThreads
def __launchThreads(self, numThreads): """Launch some threads and start to process users. :param numThreads: number of thrads to launch. :type numThreads: int. """ i = 0 while i < numThreads: self.__logger.debug("Launching thread number " + ...
python
def __launchThreads(self, numThreads): """Launch some threads and start to process users. :param numThreads: number of thrads to launch. :type numThreads: int. """ i = 0 while i < numThreads: self.__logger.debug("Launching thread number " + ...
[ "def", "__launchThreads", "(", "self", ",", "numThreads", ")", ":", "i", "=", "0", "while", "i", "<", "numThreads", ":", "self", ".", "__logger", ".", "debug", "(", "\"Launching thread number \"", "+", "str", "(", "i", ")", ")", "i", "+=", "1", "newThr...
Launch some threads and start to process users. :param numThreads: number of thrads to launch. :type numThreads: int.
[ "Launch", "some", "threads", "and", "start", "to", "process", "users", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L465-L479
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.__readAPI
def __readAPI(self, url): """Read a petition to the GitHub API (private). :param url: URL to query. :type url: str. :return: the response of the API -a dictionary with these fields-: * total_count (int): number of total users that match with the searc...
python
def __readAPI(self, url): """Read a petition to the GitHub API (private). :param url: URL to query. :type url: str. :return: the response of the API -a dictionary with these fields-: * total_count (int): number of total users that match with the searc...
[ "def", "__readAPI", "(", "self", ",", "url", ")", ":", "code", "=", "0", "hdr", "=", "{", "'User-Agent'", ":", "'curl/7.43.0 (x86_64-ubuntu) \\\n libcurl/7.43.0 OpenSSL/1.0.1k zlib/1.2.8 gh-rankings-grx'", ",", "'Accept'", ":", "'application/vnd.github.v3.text-m...
Read a petition to the GitHub API (private). :param url: URL to query. :type url: str. :return: the response of the API -a dictionary with these fields-: * total_count (int): number of total users that match with the search * incomplete_results (b...
[ "Read", "a", "petition", "to", "the", "GitHub", "API", "(", "private", ")", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L481-L543
iblancasa/GitHubCity
src/githubcity/ghcity.py
GitHubCity.__getURL
def __getURL(self, page=1, start_date=None, final_date=None, order="asc"): """Get the API's URL to query to get data about users. :param page: number of the page. :param start_date: start date of the range to search users (Y-m-d). "param final_date: final da...
python
def __getURL(self, page=1, start_date=None, final_date=None, order="asc"): """Get the API's URL to query to get data about users. :param page: number of the page. :param start_date: start date of the range to search users (Y-m-d). "param final_date: final da...
[ "def", "__getURL", "(", "self", ",", "page", "=", "1", ",", "start_date", "=", "None", ",", "final_date", "=", "None", ",", "order", "=", "\"asc\"", ")", ":", "if", "not", "start_date", "or", "not", "final_date", ":", "url", "=", "self", ".", "__serv...
Get the API's URL to query to get data about users. :param page: number of the page. :param start_date: start date of the range to search users (Y-m-d). "param final_date: final date of the range to search users (Y-m-d). :param order: order of the query. Valid va...
[ "Get", "the", "API", "s", "URL", "to", "query", "to", "get", "data", "about", "users", "." ]
train
https://github.com/iblancasa/GitHubCity/blob/c5299c6859dbefbd869e2ac6ff2faff2a39cf32f/src/githubcity/ghcity.py#L545-L579
relwell/corenlp-xml-lib
corenlp_xml/coreference.py
Coreference.mentions
def mentions(self): """ Returns mentions :return: list of mentions :rtype: list """ if self._mentions is None: self._mentions = [] for mention_element in self._element.xpath('mention'): this_mention = Mention(self, mention_element...
python
def mentions(self): """ Returns mentions :return: list of mentions :rtype: list """ if self._mentions is None: self._mentions = [] for mention_element in self._element.xpath('mention'): this_mention = Mention(self, mention_element...
[ "def", "mentions", "(", "self", ")", ":", "if", "self", ".", "_mentions", "is", "None", ":", "self", ".", "_mentions", "=", "[", "]", "for", "mention_element", "in", "self", ".", "_element", ".", "xpath", "(", "'mention'", ")", ":", "this_mention", "="...
Returns mentions :return: list of mentions :rtype: list
[ "Returns", "mentions" ]
train
https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/coreference.py#L27-L42
relwell/corenlp-xml-lib
corenlp_xml/coreference.py
Mention.sentence
def sentence(self): """ The sentence related to this mention :getter: returns the sentence this mention relates to :type: corenlp_xml.document.Sentence """ if self._sentence is None: sentences = self._element.xpath('sentence/text()') if len(sente...
python
def sentence(self): """ The sentence related to this mention :getter: returns the sentence this mention relates to :type: corenlp_xml.document.Sentence """ if self._sentence is None: sentences = self._element.xpath('sentence/text()') if len(sente...
[ "def", "sentence", "(", "self", ")", ":", "if", "self", ".", "_sentence", "is", "None", ":", "sentences", "=", "self", ".", "_element", ".", "xpath", "(", "'sentence/text()'", ")", "if", "len", "(", "sentences", ")", ">", "0", ":", "self", ".", "_sen...
The sentence related to this mention :getter: returns the sentence this mention relates to :type: corenlp_xml.document.Sentence
[ "The", "sentence", "related", "to", "this", "mention" ]
train
https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/coreference.py#L86-L98
relwell/corenlp-xml-lib
corenlp_xml/coreference.py
Mention.head
def head(self): """ The token serving as the "head" of the mention :getter: the token corresponding to the head :type: corenlp_xml.document.Token """ if self._head is None: self._head = self.sentence.tokens[self._head_id-1] return self._head
python
def head(self): """ The token serving as the "head" of the mention :getter: the token corresponding to the head :type: corenlp_xml.document.Token """ if self._head is None: self._head = self.sentence.tokens[self._head_id-1] return self._head
[ "def", "head", "(", "self", ")", ":", "if", "self", ".", "_head", "is", "None", ":", "self", ".", "_head", "=", "self", ".", "sentence", ".", "tokens", "[", "self", ".", "_head_id", "-", "1", "]", "return", "self", ".", "_head" ]
The token serving as the "head" of the mention :getter: the token corresponding to the head :type: corenlp_xml.document.Token
[ "The", "token", "serving", "as", "the", "head", "of", "the", "mention" ]
train
https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/coreference.py#L123-L133
cryptojuice/flask-scrypt
flask_scrypt.py
enbase64
def enbase64(byte_str): """ Encode bytes/strings to base64. Args: - ``byte_str``: The string or bytes to base64 encode. Returns: - byte_str encoded as base64. """ # Python 3: base64.b64encode() expects type byte if isinstance(byte_str, str) and not PYTHON2: byte_s...
python
def enbase64(byte_str): """ Encode bytes/strings to base64. Args: - ``byte_str``: The string or bytes to base64 encode. Returns: - byte_str encoded as base64. """ # Python 3: base64.b64encode() expects type byte if isinstance(byte_str, str) and not PYTHON2: byte_s...
[ "def", "enbase64", "(", "byte_str", ")", ":", "# Python 3: base64.b64encode() expects type byte", "if", "isinstance", "(", "byte_str", ",", "str", ")", "and", "not", "PYTHON2", ":", "byte_str", "=", "bytes", "(", "byte_str", ",", "'utf-8'", ")", "return", "base6...
Encode bytes/strings to base64. Args: - ``byte_str``: The string or bytes to base64 encode. Returns: - byte_str encoded as base64.
[ "Encode", "bytes", "/", "strings", "to", "base64", "." ]
train
https://github.com/cryptojuice/flask-scrypt/blob/d7f01d0d97fa36b21caa30b49c22945177799886/flask_scrypt.py#L38-L52
cryptojuice/flask-scrypt
flask_scrypt.py
debase64
def debase64(byte_str): """ Decode base64 encoded bytes/strings. Args: - ``byte_str``: The string or bytes to base64 encode. Returns: - decoded string as type str for python2 and type byte for python3. """ # Python 3: base64.b64decode() expects type byte if isinstance(byt...
python
def debase64(byte_str): """ Decode base64 encoded bytes/strings. Args: - ``byte_str``: The string or bytes to base64 encode. Returns: - decoded string as type str for python2 and type byte for python3. """ # Python 3: base64.b64decode() expects type byte if isinstance(byt...
[ "def", "debase64", "(", "byte_str", ")", ":", "# Python 3: base64.b64decode() expects type byte", "if", "isinstance", "(", "byte_str", ",", "str", ")", "and", "not", "PYTHON2", ":", "byte_str", "=", "bytes", "(", "byte_str", ",", "'utf-8'", ")", "return", "base6...
Decode base64 encoded bytes/strings. Args: - ``byte_str``: The string or bytes to base64 encode. Returns: - decoded string as type str for python2 and type byte for python3.
[ "Decode", "base64", "encoded", "bytes", "/", "strings", "." ]
train
https://github.com/cryptojuice/flask-scrypt/blob/d7f01d0d97fa36b21caa30b49c22945177799886/flask_scrypt.py#L54-L67
cryptojuice/flask-scrypt
flask_scrypt.py
generate_password_hash
def generate_password_hash(password, salt, N=1 << 14, r=8, p=1, buflen=64): """ Generate password hash givin the password string and salt. Args: - ``password``: Password string. - ``salt`` : Random base64 encoded string. Optional args: - ``N`` : the CPU cost, must be a power of...
python
def generate_password_hash(password, salt, N=1 << 14, r=8, p=1, buflen=64): """ Generate password hash givin the password string and salt. Args: - ``password``: Password string. - ``salt`` : Random base64 encoded string. Optional args: - ``N`` : the CPU cost, must be a power of...
[ "def", "generate_password_hash", "(", "password", ",", "salt", ",", "N", "=", "1", "<<", "14", ",", "r", "=", "8", ",", "p", "=", "1", ",", "buflen", "=", "64", ")", ":", "if", "PYTHON2", ":", "password", "=", "password", ".", "encode", "(", "'ut...
Generate password hash givin the password string and salt. Args: - ``password``: Password string. - ``salt`` : Random base64 encoded string. Optional args: - ``N`` : the CPU cost, must be a power of 2 greater than 1, defaults to 1 << 14. - ``r`` : the memory cost, defaults to 8...
[ "Generate", "password", "hash", "givin", "the", "password", "string", "and", "salt", "." ]
train
https://github.com/cryptojuice/flask-scrypt/blob/d7f01d0d97fa36b21caa30b49c22945177799886/flask_scrypt.py#L69-L95
cryptojuice/flask-scrypt
flask_scrypt.py
check_password_hash
def check_password_hash(password, password_hash, salt, N=1 << 14, r=8, p=1, buflen=64): """ Given a password, hash, salt this function verifies the password is equal to hash/salt. Args: - ``password``: The password to perform check on. Returns: - ``bool`` """ candidate_hash = gen...
python
def check_password_hash(password, password_hash, salt, N=1 << 14, r=8, p=1, buflen=64): """ Given a password, hash, salt this function verifies the password is equal to hash/salt. Args: - ``password``: The password to perform check on. Returns: - ``bool`` """ candidate_hash = gen...
[ "def", "check_password_hash", "(", "password", ",", "password_hash", ",", "salt", ",", "N", "=", "1", "<<", "14", ",", "r", "=", "8", ",", "p", "=", "1", ",", "buflen", "=", "64", ")", ":", "candidate_hash", "=", "generate_password_hash", "(", "passwor...
Given a password, hash, salt this function verifies the password is equal to hash/salt. Args: - ``password``: The password to perform check on. Returns: - ``bool``
[ "Given", "a", "password", "hash", "salt", "this", "function", "verifies", "the", "password", "is", "equal", "to", "hash", "/", "salt", "." ]
train
https://github.com/cryptojuice/flask-scrypt/blob/d7f01d0d97fa36b21caa30b49c22945177799886/flask_scrypt.py#L109-L121
grahambell/pymoc
lib/pymoc/io/ascii.py
write_moc_ascii
def write_moc_ascii(moc, filename=None, file=None): """Write a MOC to an ASCII file. Either a filename, or an open file object can be specified. """ orders = [] for (order, cells) in moc: ranges = [] rmin = rmax = None for cell in sorted(cells): if rmin is Non...
python
def write_moc_ascii(moc, filename=None, file=None): """Write a MOC to an ASCII file. Either a filename, or an open file object can be specified. """ orders = [] for (order, cells) in moc: ranges = [] rmin = rmax = None for cell in sorted(cells): if rmin is Non...
[ "def", "write_moc_ascii", "(", "moc", ",", "filename", "=", "None", ",", "file", "=", "None", ")", ":", "orders", "=", "[", "]", "for", "(", "order", ",", "cells", ")", "in", "moc", ":", "ranges", "=", "[", "]", "rmin", "=", "rmax", "=", "None", ...
Write a MOC to an ASCII file. Either a filename, or an open file object can be specified.
[ "Write", "a", "MOC", "to", "an", "ASCII", "file", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/io/ascii.py#L20-L49
grahambell/pymoc
lib/pymoc/io/ascii.py
read_moc_ascii
def read_moc_ascii(moc, filename=None, file=None): """Read from an ASCII file into a MOC. Either a filename, or an open file object can be specified. """ if file is not None: orders = _read_ascii(file) else: with open(filename, 'r') as f: orders = _read_ascii(f) fo...
python
def read_moc_ascii(moc, filename=None, file=None): """Read from an ASCII file into a MOC. Either a filename, or an open file object can be specified. """ if file is not None: orders = _read_ascii(file) else: with open(filename, 'r') as f: orders = _read_ascii(f) fo...
[ "def", "read_moc_ascii", "(", "moc", ",", "filename", "=", "None", ",", "file", "=", "None", ")", ":", "if", "file", "is", "not", "None", ":", "orders", "=", "_read_ascii", "(", "file", ")", "else", ":", "with", "open", "(", "filename", ",", "'r'", ...
Read from an ASCII file into a MOC. Either a filename, or an open file object can be specified.
[ "Read", "from", "an", "ASCII", "file", "into", "a", "MOC", "." ]
train
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/io/ascii.py#L52-L77
1flow/python-ftr
ftr/app/__init__.py
index
def index(): """ Base testsuite view. """ # setup_env() logs = Table('log', metadata, autoload=True) criticals = logs.select().where(logs.c.log_level == 50).order_by( 'siteconfig', 'date_created') criticals_count = logs.count(logs.c.log_level == 50) errors = logs.select().where(logs....
python
def index(): """ Base testsuite view. """ # setup_env() logs = Table('log', metadata, autoload=True) criticals = logs.select().where(logs.c.log_level == 50).order_by( 'siteconfig', 'date_created') criticals_count = logs.count(logs.c.log_level == 50) errors = logs.select().where(logs....
[ "def", "index", "(", ")", ":", "# setup_env()", "logs", "=", "Table", "(", "'log'", ",", "metadata", ",", "autoload", "=", "True", ")", "criticals", "=", "logs", ".", "select", "(", ")", ".", "where", "(", "logs", ".", "c", ".", "log_level", "==", ...
Base testsuite view.
[ "Base", "testsuite", "view", "." ]
train
https://github.com/1flow/python-ftr/blob/90a2108c5ee005f1bf66dbe8cce68f2b7051b839/ftr/app/__init__.py#L245-L278
1flow/python-ftr
ftr/app/__init__.py
SQLiteHandler.emit
def emit(self, record): """ Handle the logging call. """ if bool(self.store_only): do_not_store = True for extra in self.store_only: if bool(getattr(record, extra, None)): do_not_store = False break if do_not_s...
python
def emit(self, record): """ Handle the logging call. """ if bool(self.store_only): do_not_store = True for extra in self.store_only: if bool(getattr(record, extra, None)): do_not_store = False break if do_not_s...
[ "def", "emit", "(", "self", ",", "record", ")", ":", "if", "bool", "(", "self", ".", "store_only", ")", ":", "do_not_store", "=", "True", "for", "extra", "in", "self", ".", "store_only", ":", "if", "bool", "(", "getattr", "(", "record", ",", "extra",...
Handle the logging call.
[ "Handle", "the", "logging", "call", "." ]
train
https://github.com/1flow/python-ftr/blob/90a2108c5ee005f1bf66dbe8cce68f2b7051b839/ftr/app/__init__.py#L129-L195
royi1000/py-libhdate
hdate/common.py
Location.timezone
def timezone(self, value): """Set the timezone.""" self._timezone = (value if isinstance(value, datetime.tzinfo) else tz.gettz(value))
python
def timezone(self, value): """Set the timezone.""" self._timezone = (value if isinstance(value, datetime.tzinfo) else tz.gettz(value))
[ "def", "timezone", "(", "self", ",", "value", ")", ":", "self", ".", "_timezone", "=", "(", "value", "if", "isinstance", "(", "value", ",", "datetime", ".", "tzinfo", ")", "else", "tz", ".", "gettz", "(", "value", ")", ")" ]
Set the timezone.
[ "Set", "the", "timezone", "." ]
train
https://github.com/royi1000/py-libhdate/blob/12af759fb69f1d6403abed3762beaf5ace16a34b/hdate/common.py#L66-L69
cgarciae/dataget
dataget/__coconut__.py
recursive_iterator
def recursive_iterator(func): """Decorates a function by optimizing it for iterator recursion. Requires function arguments to be pickleable.""" tee_store = {} @_coconut.functools.wraps(func) def recursive_iterator_func(*args, **kwargs): hashable_args_kwargs = _coconut.pickle.dumps((args, kwa...
python
def recursive_iterator(func): """Decorates a function by optimizing it for iterator recursion. Requires function arguments to be pickleable.""" tee_store = {} @_coconut.functools.wraps(func) def recursive_iterator_func(*args, **kwargs): hashable_args_kwargs = _coconut.pickle.dumps((args, kwa...
[ "def", "recursive_iterator", "(", "func", ")", ":", "tee_store", "=", "{", "}", "@", "_coconut", ".", "functools", ".", "wraps", "(", "func", ")", "def", "recursive_iterator_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "hashable_args_kwargs"...
Decorates a function by optimizing it for iterator recursion. Requires function arguments to be pickleable.
[ "Decorates", "a", "function", "by", "optimizing", "it", "for", "iterator", "recursion", ".", "Requires", "function", "arguments", "to", "be", "pickleable", "." ]
train
https://github.com/cgarciae/dataget/blob/04d3d9c68ebdcbed103605731a1be0f26e1c36fa/dataget/__coconut__.py#L411-L424
cgarciae/dataget
dataget/__coconut__.py
addpattern
def addpattern(base_func): """Decorator to add a new case to a pattern-matching function, where the new case is checked last.""" def pattern_adder(func): @_coconut.functools.wraps(func) @_coconut_tco def add_pattern_func(*args, **kwargs): try: return base_func...
python
def addpattern(base_func): """Decorator to add a new case to a pattern-matching function, where the new case is checked last.""" def pattern_adder(func): @_coconut.functools.wraps(func) @_coconut_tco def add_pattern_func(*args, **kwargs): try: return base_func...
[ "def", "addpattern", "(", "base_func", ")", ":", "def", "pattern_adder", "(", "func", ")", ":", "@", "_coconut", ".", "functools", ".", "wraps", "(", "func", ")", "@", "_coconut_tco", "def", "add_pattern_func", "(", "*", "args", ",", "*", "*", "kwargs", ...
Decorator to add a new case to a pattern-matching function, where the new case is checked last.
[ "Decorator", "to", "add", "a", "new", "case", "to", "a", "pattern", "-", "matching", "function", "where", "the", "new", "case", "is", "checked", "last", "." ]
train
https://github.com/cgarciae/dataget/blob/04d3d9c68ebdcbed103605731a1be0f26e1c36fa/dataget/__coconut__.py#L425-L436
cgarciae/dataget
dataget/__coconut__.py
fmap
def fmap(func, obj): """Creates a copy of obj with func applied to its contents.""" if _coconut.hasattr(obj, "__fmap__"): return obj.__fmap__(func) args = _coconut_map(func, obj) if _coconut.isinstance(obj, _coconut.dict): args = _coconut_zip(args, obj.values()) if _coconut.isinstanc...
python
def fmap(func, obj): """Creates a copy of obj with func applied to its contents.""" if _coconut.hasattr(obj, "__fmap__"): return obj.__fmap__(func) args = _coconut_map(func, obj) if _coconut.isinstance(obj, _coconut.dict): args = _coconut_zip(args, obj.values()) if _coconut.isinstanc...
[ "def", "fmap", "(", "func", ",", "obj", ")", ":", "if", "_coconut", ".", "hasattr", "(", "obj", ",", "\"__fmap__\"", ")", ":", "return", "obj", ".", "__fmap__", "(", "func", ")", "args", "=", "_coconut_map", "(", "func", ",", "obj", ")", "if", "_co...
Creates a copy of obj with func applied to its contents.
[ "Creates", "a", "copy", "of", "obj", "with", "func", "applied", "to", "its", "contents", "." ]
train
https://github.com/cgarciae/dataget/blob/04d3d9c68ebdcbed103605731a1be0f26e1c36fa/dataget/__coconut__.py#L498-L511
cgarciae/dataget
dataget/__coconut__.py
reversed.index
def index(self, elem): """Find the index of elem in the reversed iterator.""" return _coconut.len(self._iter) - self._iter.index(elem) - 1
python
def index(self, elem): """Find the index of elem in the reversed iterator.""" return _coconut.len(self._iter) - self._iter.index(elem) - 1
[ "def", "index", "(", "self", ",", "elem", ")", ":", "return", "_coconut", ".", "len", "(", "self", ".", "_iter", ")", "-", "self", ".", "_iter", ".", "index", "(", "elem", ")", "-", "1" ]
Find the index of elem in the reversed iterator.
[ "Find", "the", "index", "of", "elem", "in", "the", "reversed", "iterator", "." ]
train
https://github.com/cgarciae/dataget/blob/04d3d9c68ebdcbed103605731a1be0f26e1c36fa/dataget/__coconut__.py#L244-L246
cgarciae/dataget
dataget/__coconut__.py
count.index
def index(self, elem): """Find the index of elem in the count.""" if elem not in self: raise _coconut.ValueError(_coconut.repr(elem) + " is not in count") return (elem - self._start) // self._step
python
def index(self, elem): """Find the index of elem in the count.""" if elem not in self: raise _coconut.ValueError(_coconut.repr(elem) + " is not in count") return (elem - self._start) // self._step
[ "def", "index", "(", "self", ",", "elem", ")", ":", "if", "elem", "not", "in", "self", ":", "raise", "_coconut", ".", "ValueError", "(", "_coconut", ".", "repr", "(", "elem", ")", "+", "\" is not in count\"", ")", "return", "(", "elem", "-", "self", ...
Find the index of elem in the count.
[ "Find", "the", "index", "of", "elem", "in", "the", "count", "." ]
train
https://github.com/cgarciae/dataget/blob/04d3d9c68ebdcbed103605731a1be0f26e1c36fa/dataget/__coconut__.py#L394-L398
dacut/python-aws-sig
awssig/sigv4.py
normalize_uri_path_component
def normalize_uri_path_component(path_component): """ normalize_uri_path_component(path_component) -> str Normalize the path component according to RFC 3986. This performs the following operations: * Alpha, digit, and the symbols '-', '.', '_', and '~' (unreserved characters) are left alone....
python
def normalize_uri_path_component(path_component): """ normalize_uri_path_component(path_component) -> str Normalize the path component according to RFC 3986. This performs the following operations: * Alpha, digit, and the symbols '-', '.', '_', and '~' (unreserved characters) are left alone....
[ "def", "normalize_uri_path_component", "(", "path_component", ")", ":", "result", "=", "BytesIO", "(", ")", "i", "=", "0", "path_component", "=", "path_component", ".", "encode", "(", "\"utf-8\"", ")", "while", "i", "<", "len", "(", "path_component", ")", ":...
normalize_uri_path_component(path_component) -> str Normalize the path component according to RFC 3986. This performs the following operations: * Alpha, digit, and the symbols '-', '.', '_', and '~' (unreserved characters) are left alone. * Characters outside this range are percent-encoded. ...
[ "normalize_uri_path_component", "(", "path_component", ")", "-", ">", "str" ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L385-L439
dacut/python-aws-sig
awssig/sigv4.py
get_canonical_uri_path
def get_canonical_uri_path(uri_path): """ get_canonical_uri_path(uri_path) -> str Normalizes the specified URI path component, removing redundant slashes and relative path components. A ValueError exception is raised if: * The URI path is not empty and not absolute (does not start with '/'). ...
python
def get_canonical_uri_path(uri_path): """ get_canonical_uri_path(uri_path) -> str Normalizes the specified URI path component, removing redundant slashes and relative path components. A ValueError exception is raised if: * The URI path is not empty and not absolute (does not start with '/'). ...
[ "def", "get_canonical_uri_path", "(", "uri_path", ")", ":", "# Special case: empty path is converted to '/'", "if", "uri_path", "==", "\"\"", "or", "uri_path", "==", "\"/\"", ":", "return", "\"/\"", "# All other paths must be absolute.", "if", "not", "uri_path", ".", "s...
get_canonical_uri_path(uri_path) -> str Normalizes the specified URI path component, removing redundant slashes and relative path components. A ValueError exception is raised if: * The URI path is not empty and not absolute (does not start with '/'). * A parent relative path element ('..') attempt...
[ "get_canonical_uri_path", "(", "uri_path", ")", "-", ">", "str" ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L441-L494
dacut/python-aws-sig
awssig/sigv4.py
normalize_query_parameters
def normalize_query_parameters(query_string): """ normalize_query_parameters(query_string) -> dict Converts a query string into a dictionary mapping parameter names to a list of the sorted values. This ensurses that the query string follows % encoding rules according to RFC 3986 and checks for dup...
python
def normalize_query_parameters(query_string): """ normalize_query_parameters(query_string) -> dict Converts a query string into a dictionary mapping parameter names to a list of the sorted values. This ensurses that the query string follows % encoding rules according to RFC 3986 and checks for dup...
[ "def", "normalize_query_parameters", "(", "query_string", ")", ":", "if", "query_string", "==", "\"\"", ":", "return", "{", "}", "components", "=", "query_string", ".", "split", "(", "\"&\"", ")", "result", "=", "{", "}", "for", "component", "in", "component...
normalize_query_parameters(query_string) -> dict Converts a query string into a dictionary mapping parameter names to a list of the sorted values. This ensurses that the query string follows % encoding rules according to RFC 3986 and checks for duplicate keys. A ValueError exception is raised if a pe...
[ "normalize_query_parameters", "(", "query_string", ")", "-", ">", "dict" ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L496-L532
dacut/python-aws-sig
awssig/sigv4.py
AWSSigV4Verifier.canonical_uri_path
def canonical_uri_path(self): """ The canonicalized URI path from the request. """ result = getattr(self, "_canonical_uri_path", None) if result is None: result = self._canonical_uri_path = get_canonical_uri_path( self.uri_path) return result
python
def canonical_uri_path(self): """ The canonicalized URI path from the request. """ result = getattr(self, "_canonical_uri_path", None) if result is None: result = self._canonical_uri_path = get_canonical_uri_path( self.uri_path) return result
[ "def", "canonical_uri_path", "(", "self", ")", ":", "result", "=", "getattr", "(", "self", ",", "\"_canonical_uri_path\"", ",", "None", ")", "if", "result", "is", "None", ":", "result", "=", "self", ".", "_canonical_uri_path", "=", "get_canonical_uri_path", "(...
The canonicalized URI path from the request.
[ "The", "canonicalized", "URI", "path", "from", "the", "request", "." ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L104-L112
dacut/python-aws-sig
awssig/sigv4.py
AWSSigV4Verifier.query_parameters
def query_parameters(self): """ A key to list of values mapping of the query parameters seen in the request. """ result = getattr(self, "_query_parameters", None) if result is None: result = self._query_parameters = normalize_query_parameters( ...
python
def query_parameters(self): """ A key to list of values mapping of the query parameters seen in the request. """ result = getattr(self, "_query_parameters", None) if result is None: result = self._query_parameters = normalize_query_parameters( ...
[ "def", "query_parameters", "(", "self", ")", ":", "result", "=", "getattr", "(", "self", ",", "\"_query_parameters\"", ",", "None", ")", "if", "result", "is", "None", ":", "result", "=", "self", ".", "_query_parameters", "=", "normalize_query_parameters", "(",...
A key to list of values mapping of the query parameters seen in the request.
[ "A", "key", "to", "list", "of", "values", "mapping", "of", "the", "query", "parameters", "seen", "in", "the", "request", "." ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L115-L124
dacut/python-aws-sig
awssig/sigv4.py
AWSSigV4Verifier.canonical_query_string
def canonical_query_string(self): """ The canonical query string from the query parameters. This takes the query string from the request and orders the parameters in """ results = [] for key, values in iteritems(self.query_parameters): # Don't includ...
python
def canonical_query_string(self): """ The canonical query string from the query parameters. This takes the query string from the request and orders the parameters in """ results = [] for key, values in iteritems(self.query_parameters): # Don't includ...
[ "def", "canonical_query_string", "(", "self", ")", ":", "results", "=", "[", "]", "for", "key", ",", "values", "in", "iteritems", "(", "self", ".", "query_parameters", ")", ":", "# Don't include the signature itself.", "if", "key", "==", "_x_amz_signature", ":",...
The canonical query string from the query parameters. This takes the query string from the request and orders the parameters in
[ "The", "canonical", "query", "string", "from", "the", "query", "parameters", "." ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L127-L143
dacut/python-aws-sig
awssig/sigv4.py
AWSSigV4Verifier.authorization_header_parameters
def authorization_header_parameters(self): """ The parameters from the Authorization header (only). If the Authorization header is not present or is not an AWS SigV4 header, an AttributeError exception is raised. """ result = getattr(self, "_authorization_header_paramete...
python
def authorization_header_parameters(self): """ The parameters from the Authorization header (only). If the Authorization header is not present or is not an AWS SigV4 header, an AttributeError exception is raised. """ result = getattr(self, "_authorization_header_paramete...
[ "def", "authorization_header_parameters", "(", "self", ")", ":", "result", "=", "getattr", "(", "self", ",", "\"_authorization_header_parameters\"", ",", "None", ")", "if", "result", "is", "None", ":", "auth", "=", "self", ".", "headers", ".", "get", "(", "_...
The parameters from the Authorization header (only). If the Authorization header is not present or is not an AWS SigV4 header, an AttributeError exception is raised.
[ "The", "parameters", "from", "the", "Authorization", "header", "(", "only", ")", ".", "If", "the", "Authorization", "header", "is", "not", "present", "or", "is", "not", "an", "AWS", "SigV4", "header", "an", "AttributeError", "exception", "is", "raised", "." ...
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L146-L177
dacut/python-aws-sig
awssig/sigv4.py
AWSSigV4Verifier.signed_headers
def signed_headers(self): """ An ordered dictionary containing the signed header names and values. """ # See if the signed headers are listed in the query string signed_headers = self.query_parameters.get(_x_amz_signedheaders) if signed_headers is not None: si...
python
def signed_headers(self): """ An ordered dictionary containing the signed header names and values. """ # See if the signed headers are listed in the query string signed_headers = self.query_parameters.get(_x_amz_signedheaders) if signed_headers is not None: si...
[ "def", "signed_headers", "(", "self", ")", ":", "# See if the signed headers are listed in the query string", "signed_headers", "=", "self", ".", "query_parameters", ".", "get", "(", "_x_amz_signedheaders", ")", "if", "signed_headers", "is", "not", "None", ":", "signed_...
An ordered dictionary containing the signed header names and values.
[ "An", "ordered", "dictionary", "containing", "the", "signed", "header", "names", "and", "values", "." ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L180-L205
dacut/python-aws-sig
awssig/sigv4.py
AWSSigV4Verifier.request_timestamp
def request_timestamp(self): """ The timestamp of the request in ISO8601 YYYYMMDD'T'HHMMSS'Z' format. If this is not available in the query parameters or headers, or the value is not a valid format for AWS SigV4, an AttributeError exception is raised. """ amz_dat...
python
def request_timestamp(self): """ The timestamp of the request in ISO8601 YYYYMMDD'T'HHMMSS'Z' format. If this is not available in the query parameters or headers, or the value is not a valid format for AWS SigV4, an AttributeError exception is raised. """ amz_dat...
[ "def", "request_timestamp", "(", "self", ")", ":", "amz_date", "=", "self", ".", "query_parameters", ".", "get", "(", "_x_amz_date", ")", "if", "amz_date", "is", "not", "None", ":", "amz_date", "=", "amz_date", "[", "0", "]", "else", ":", "amz_date", "="...
The timestamp of the request in ISO8601 YYYYMMDD'T'HHMMSS'Z' format. If this is not available in the query parameters or headers, or the value is not a valid format for AWS SigV4, an AttributeError exception is raised.
[ "The", "timestamp", "of", "the", "request", "in", "ISO8601", "YYYYMMDD", "T", "HHMMSS", "Z", "format", "." ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L219-L249
dacut/python-aws-sig
awssig/sigv4.py
AWSSigV4Verifier.access_key
def access_key(self): """ The access key id used to sign the request. If the access key is not in the same credential scope as this request, an AttributeError exception is raised. """ credential = self.query_parameters.get(_x_amz_credential) if credential is not ...
python
def access_key(self): """ The access key id used to sign the request. If the access key is not in the same credential scope as this request, an AttributeError exception is raised. """ credential = self.query_parameters.get(_x_amz_credential) if credential is not ...
[ "def", "access_key", "(", "self", ")", ":", "credential", "=", "self", ".", "query_parameters", ".", "get", "(", "_x_amz_credential", ")", "if", "credential", "is", "not", "None", ":", "credential", "=", "url_unquote", "(", "credential", "[", "0", "]", ")"...
The access key id used to sign the request. If the access key is not in the same credential scope as this request, an AttributeError exception is raised.
[ "The", "access", "key", "id", "used", "to", "sign", "the", "request", "." ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L260-L284
dacut/python-aws-sig
awssig/sigv4.py
AWSSigV4Verifier.request_signature
def request_signature(self): """ The signature passed in the request. """ signature = self.query_parameters.get(_x_amz_signature) if signature is not None: signature = signature[0] else: signature = self.authorization_header_parameters.get(_signatu...
python
def request_signature(self): """ The signature passed in the request. """ signature = self.query_parameters.get(_x_amz_signature) if signature is not None: signature = signature[0] else: signature = self.authorization_header_parameters.get(_signatu...
[ "def", "request_signature", "(", "self", ")", ":", "signature", "=", "self", ".", "query_parameters", ".", "get", "(", "_x_amz_signature", ")", "if", "signature", "is", "not", "None", ":", "signature", "=", "signature", "[", "0", "]", "else", ":", "signatu...
The signature passed in the request.
[ "The", "signature", "passed", "in", "the", "request", "." ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L287-L299
dacut/python-aws-sig
awssig/sigv4.py
AWSSigV4Verifier.canonical_request
def canonical_request(self): """ The AWS SigV4 canonical request given parameters from an HTTP request. This process is outlined here: http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html The canonical request is: request_method + '\n' + ...
python
def canonical_request(self): """ The AWS SigV4 canonical request given parameters from an HTTP request. This process is outlined here: http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html The canonical request is: request_method + '\n' + ...
[ "def", "canonical_request", "(", "self", ")", ":", "signed_headers", "=", "self", ".", "signed_headers", "header_lines", "=", "\"\"", ".", "join", "(", "[", "\"%s:%s\\n\"", "%", "item", "for", "item", "in", "iteritems", "(", "signed_headers", ")", "]", ")", ...
The AWS SigV4 canonical request given parameters from an HTTP request. This process is outlined here: http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html The canonical request is: request_method + '\n' + canonical_uri_path + '\n' + ...
[ "The", "AWS", "SigV4", "canonical", "request", "given", "parameters", "from", "an", "HTTP", "request", ".", "This", "process", "is", "outlined", "here", ":", "http", ":", "//", "docs", ".", "aws", ".", "amazon", ".", "com", "/", "general", "/", "latest",...
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L302-L325
dacut/python-aws-sig
awssig/sigv4.py
AWSSigV4Verifier.string_to_sign
def string_to_sign(self): """ The AWS SigV4 string being signed. """ return (AWS4_HMAC_SHA256 + "\n" + self.request_timestamp + "\n" + self.credential_scope + "\n" + sha256(self.canonical_request.encode("utf-8")).hexdigest())
python
def string_to_sign(self): """ The AWS SigV4 string being signed. """ return (AWS4_HMAC_SHA256 + "\n" + self.request_timestamp + "\n" + self.credential_scope + "\n" + sha256(self.canonical_request.encode("utf-8")).hexdigest())
[ "def", "string_to_sign", "(", "self", ")", ":", "return", "(", "AWS4_HMAC_SHA256", "+", "\"\\n\"", "+", "self", ".", "request_timestamp", "+", "\"\\n\"", "+", "self", ".", "credential_scope", "+", "\"\\n\"", "+", "sha256", "(", "self", ".", "canonical_request"...
The AWS SigV4 string being signed.
[ "The", "AWS", "SigV4", "string", "being", "signed", "." ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L328-L335
dacut/python-aws-sig
awssig/sigv4.py
AWSSigV4Verifier.expected_signature
def expected_signature(self): """ The AWS SigV4 signature expected from the request. """ k_secret = b"AWS4" + self.key_mapping[self.access_key].encode("utf-8") k_date = hmac.new(k_secret, self.request_date.encode("utf-8"), sha256).digest() k_regi...
python
def expected_signature(self): """ The AWS SigV4 signature expected from the request. """ k_secret = b"AWS4" + self.key_mapping[self.access_key].encode("utf-8") k_date = hmac.new(k_secret, self.request_date.encode("utf-8"), sha256).digest() k_regi...
[ "def", "expected_signature", "(", "self", ")", ":", "k_secret", "=", "b\"AWS4\"", "+", "self", ".", "key_mapping", "[", "self", ".", "access_key", "]", ".", "encode", "(", "\"utf-8\"", ")", "k_date", "=", "hmac", ".", "new", "(", "k_secret", ",", "self",...
The AWS SigV4 signature expected from the request.
[ "The", "AWS", "SigV4", "signature", "expected", "from", "the", "request", "." ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L338-L352
dacut/python-aws-sig
awssig/sigv4.py
AWSSigV4Verifier.verify
def verify(self): """ Verifies that the request timestamp is not beyond our allowable timestamp mismatch and that the request signature matches our expectations. """ try: if self.timestamp_mismatch is not None: m = _iso8601_timestamp_regex.matc...
python
def verify(self): """ Verifies that the request timestamp is not beyond our allowable timestamp mismatch and that the request signature matches our expectations. """ try: if self.timestamp_mismatch is not None: m = _iso8601_timestamp_regex.matc...
[ "def", "verify", "(", "self", ")", ":", "try", ":", "if", "self", ".", "timestamp_mismatch", "is", "not", "None", ":", "m", "=", "_iso8601_timestamp_regex", ".", "match", "(", "self", ".", "request_timestamp", ")", "year", "=", "int", "(", "m", ".", "g...
Verifies that the request timestamp is not beyond our allowable timestamp mismatch and that the request signature matches our expectations.
[ "Verifies", "that", "the", "request", "timestamp", "is", "not", "beyond", "our", "allowable", "timestamp", "mismatch", "and", "that", "the", "request", "signature", "matches", "our", "expectations", "." ]
train
https://github.com/dacut/python-aws-sig/blob/7f6054dca4b32e67ca3d39db31c1b4be5efe54bd/awssig/sigv4.py#L354-L383
transmogrifier/pidigits
pidigits/taudigits.py
getTauLeibniz
def getTauLeibniz(n): """Returns a list containing first n digits of Pi """ myTau = tauGenLeibniz() result = [] if n > 0: result += [next(myTau) for i in range(n)] myTau.close() return result
python
def getTauLeibniz(n): """Returns a list containing first n digits of Pi """ myTau = tauGenLeibniz() result = [] if n > 0: result += [next(myTau) for i in range(n)] myTau.close() return result
[ "def", "getTauLeibniz", "(", "n", ")", ":", "myTau", "=", "tauGenLeibniz", "(", ")", "result", "=", "[", "]", "if", "n", ">", "0", ":", "result", "+=", "[", "next", "(", "myTau", ")", "for", "i", "in", "range", "(", "n", ")", "]", "myTau", ".",...
Returns a list containing first n digits of Pi
[ "Returns", "a", "list", "containing", "first", "n", "digits", "of", "Pi" ]
train
https://github.com/transmogrifier/pidigits/blob/b12081126a76d30fb69839aa586420c5bb04feb8/pidigits/taudigits.py#L70-L78
sgillies/rio-plugin-example
metasay/__init__.py
moothedata
def moothedata(data, key=None): """Return an amusing picture containing an item from a dict. Parameters ---------- data: mapping A mapping, such as a raster dataset's ``meta`` or ``profile`` property. key: A key of the ``data`` mapping. """ if not key: key = ...
python
def moothedata(data, key=None): """Return an amusing picture containing an item from a dict. Parameters ---------- data: mapping A mapping, such as a raster dataset's ``meta`` or ``profile`` property. key: A key of the ``data`` mapping. """ if not key: key = ...
[ "def", "moothedata", "(", "data", ",", "key", "=", "None", ")", ":", "if", "not", "key", ":", "key", "=", "choice", "(", "list", "(", "data", ".", "keys", "(", ")", ")", ")", "logger", ".", "debug", "(", "\"Using randomly chosen key: %s\"", ",", "key...
Return an amusing picture containing an item from a dict. Parameters ---------- data: mapping A mapping, such as a raster dataset's ``meta`` or ``profile`` property. key: A key of the ``data`` mapping.
[ "Return", "an", "amusing", "picture", "containing", "an", "item", "from", "a", "dict", "." ]
train
https://github.com/sgillies/rio-plugin-example/blob/31e7383e9f0ee7d7fc07d3ba4f2fe2a1602c9579/metasay/__init__.py#L18-L33
buckmaxwell/neoapi
neoapi/serializable_structured_node.py
SerializableStructuredNode.resource_collection_response
def resource_collection_response(cls, offset=0, limit=20): """ This method is deprecated for version 1.1.0. Please use get_collection """ request_args = {'page[offset]': offset, 'page[limit]': limit} return cls.get_collection(request_args)
python
def resource_collection_response(cls, offset=0, limit=20): """ This method is deprecated for version 1.1.0. Please use get_collection """ request_args = {'page[offset]': offset, 'page[limit]': limit} return cls.get_collection(request_args)
[ "def", "resource_collection_response", "(", "cls", ",", "offset", "=", "0", ",", "limit", "=", "20", ")", ":", "request_args", "=", "{", "'page[offset]'", ":", "offset", ",", "'page[limit]'", ":", "limit", "}", "return", "cls", ".", "get_collection", "(", ...
This method is deprecated for version 1.1.0. Please use get_collection
[ "This", "method", "is", "deprecated", "for", "version", "1", ".", "1", ".", "0", ".", "Please", "use", "get_collection" ]
train
https://github.com/buckmaxwell/neoapi/blob/96c5d83c847d7a12d3d1f17931d85776f5280877/neoapi/serializable_structured_node.py#L42-L47
buckmaxwell/neoapi
neoapi/serializable_structured_node.py
SerializableStructuredNode.get_collection
def get_collection(cls, request_args): r""" Used to fetch a collection of resource object of type 'cls' in response to a GET request\ . get_resource_or_collection should only be invoked on a resource when the client specifies a GET request. :param request_args: The query parameters supp...
python
def get_collection(cls, request_args): r""" Used to fetch a collection of resource object of type 'cls' in response to a GET request\ . get_resource_or_collection should only be invoked on a resource when the client specifies a GET request. :param request_args: The query parameters supp...
[ "def", "get_collection", "(", "cls", ",", "request_args", ")", ":", "try", ":", "if", "request_args", ".", "get", "(", "'include'", ")", ":", "raise", "ParameterNotSupported", "offset", "=", "request_args", ".", "get", "(", "'page[offset]'", ",", "0", ")", ...
r""" Used to fetch a collection of resource object of type 'cls' in response to a GET request\ . get_resource_or_collection should only be invoked on a resource when the client specifies a GET request. :param request_args: The query parameters supplied with the request. currently supports page...
[ "r", "Used", "to", "fetch", "a", "collection", "of", "resource", "object", "of", "type", "cls", "in", "response", "to", "a", "GET", "request", "\\", ".", "get_resource_or_collection", "should", "only", "be", "invoked", "on", "a", "resource", "when", "the", ...
train
https://github.com/buckmaxwell/neoapi/blob/96c5d83c847d7a12d3d1f17931d85776f5280877/neoapi/serializable_structured_node.py#L462-L529
buckmaxwell/neoapi
neoapi/serializable_structured_node.py
SerializableStructuredNode.get_resource
def get_resource(cls, request_args, id): r""" Used to fetch a single resource object with the given id in response to a GET request.\ get_resource should only be invoked on a resource when the client specifies a GET request. :param request_args: :return: The query parameters sup...
python
def get_resource(cls, request_args, id): r""" Used to fetch a single resource object with the given id in response to a GET request.\ get_resource should only be invoked on a resource when the client specifies a GET request. :param request_args: :return: The query parameters sup...
[ "def", "get_resource", "(", "cls", ",", "request_args", ",", "id", ")", ":", "try", ":", "this_resource", "=", "cls", ".", "nodes", ".", "get", "(", "id", "=", "id", ",", "active", "=", "True", ")", "try", ":", "included", "=", "request_args", ".", ...
r""" Used to fetch a single resource object with the given id in response to a GET request.\ get_resource should only be invoked on a resource when the client specifies a GET request. :param request_args: :return: The query parameters supplied with the request. currently supports inclu...
[ "r", "Used", "to", "fetch", "a", "single", "resource", "object", "with", "the", "given", "id", "in", "response", "to", "a", "GET", "request", ".", "\\", "get_resource", "should", "only", "be", "invoked", "on", "a", "resource", "when", "the", "client", "s...
train
https://github.com/buckmaxwell/neoapi/blob/96c5d83c847d7a12d3d1f17931d85776f5280877/neoapi/serializable_structured_node.py#L532-L553
buckmaxwell/neoapi
neoapi/serializable_structured_node.py
SerializableStructuredNode.get_resource_or_collection
def get_resource_or_collection(cls, request_args, id=None): r""" Deprecated for version 1.1.0. Please use get_resource or get_collection. This function has multiple behaviors. With id specified: Used to fetch a single resource object with the given id in response to a GET request.\ ...
python
def get_resource_or_collection(cls, request_args, id=None): r""" Deprecated for version 1.1.0. Please use get_resource or get_collection. This function has multiple behaviors. With id specified: Used to fetch a single resource object with the given id in response to a GET request.\ ...
[ "def", "get_resource_or_collection", "(", "cls", ",", "request_args", ",", "id", "=", "None", ")", ":", "if", "id", ":", "try", ":", "r", "=", "cls", ".", "get_resource", "(", "request_args", ")", "except", "DoesNotExist", ":", "r", "=", "application_codes...
r""" Deprecated for version 1.1.0. Please use get_resource or get_collection. This function has multiple behaviors. With id specified: Used to fetch a single resource object with the given id in response to a GET request.\ get_resource_or_collection should only be invoked on a resource...
[ "r", "Deprecated", "for", "version", "1", ".", "1", ".", "0", ".", "Please", "use", "get_resource", "or", "get_collection", "." ]
train
https://github.com/buckmaxwell/neoapi/blob/96c5d83c847d7a12d3d1f17931d85776f5280877/neoapi/serializable_structured_node.py#L556-L586
buckmaxwell/neoapi
neoapi/serializable_structured_node.py
SerializableStructuredNode.create_resource
def create_resource(cls, request_json): r""" Used to create a node in the database of type 'cls' in response to a POST request. create_resource should only \ be invoked on a resource when the client specifies a POST request. :param request_json: a dictionary formatted according to the s...
python
def create_resource(cls, request_json): r""" Used to create a node in the database of type 'cls' in response to a POST request. create_resource should only \ be invoked on a resource when the client specifies a POST request. :param request_json: a dictionary formatted according to the s...
[ "def", "create_resource", "(", "cls", ",", "request_json", ")", ":", "response", "=", "dict", "(", ")", "new_resource", ",", "location", "=", "None", ",", "None", "try", ":", "data", "=", "request_json", "[", "'data'", "]", "if", "data", "[", "'type'", ...
r""" Used to create a node in the database of type 'cls' in response to a POST request. create_resource should only \ be invoked on a resource when the client specifies a POST request. :param request_json: a dictionary formatted according to the specification at \ http://jsonapi.org/for...
[ "r", "Used", "to", "create", "a", "node", "in", "the", "database", "of", "type", "cls", "in", "response", "to", "a", "POST", "request", ".", "create_resource", "should", "only", "\\", "be", "invoked", "on", "a", "resource", "when", "the", "client", "spec...
train
https://github.com/buckmaxwell/neoapi/blob/96c5d83c847d7a12d3d1f17931d85776f5280877/neoapi/serializable_structured_node.py#L589-L716
buckmaxwell/neoapi
neoapi/serializable_structured_node.py
SerializableStructuredNode.deactivate_resource
def deactivate_resource(cls, id): r""" Used to deactivate a node of type 'cls' in response to a DELETE request. deactivate_resource should only \ be invoked on a resource when the client specifies a DELETE request. :param id: The 'id' field of the node to update in the database. The id...
python
def deactivate_resource(cls, id): r""" Used to deactivate a node of type 'cls' in response to a DELETE request. deactivate_resource should only \ be invoked on a resource when the client specifies a DELETE request. :param id: The 'id' field of the node to update in the database. The id...
[ "def", "deactivate_resource", "(", "cls", ",", "id", ")", ":", "try", ":", "this_resource", "=", "cls", ".", "nodes", ".", "get", "(", "id", "=", "id", ",", "active", "=", "True", ")", "this_resource", ".", "deactivate", "(", ")", "r", "=", "make_res...
r""" Used to deactivate a node of type 'cls' in response to a DELETE request. deactivate_resource should only \ be invoked on a resource when the client specifies a DELETE request. :param id: The 'id' field of the node to update in the database. The id field must be set in the model -- it \ ...
[ "r", "Used", "to", "deactivate", "a", "node", "of", "type", "cls", "in", "response", "to", "a", "DELETE", "request", ".", "deactivate_resource", "should", "only", "\\", "be", "invoked", "on", "a", "resource", "when", "the", "client", "specifies", "a", "DEL...
train
https://github.com/buckmaxwell/neoapi/blob/96c5d83c847d7a12d3d1f17931d85776f5280877/neoapi/serializable_structured_node.py#L838-L857
buckmaxwell/neoapi
neoapi/serializable_structured_node.py
SerializableStructuredNode.get_relationship
def get_relationship(cls, request_args, id, related_collection_name, related_resource=None): """ Get a relationship :param request_args: :param id: The 'id' field of the node on the left side of the relationship in the database. The id field must \ be set in the model -- it is n...
python
def get_relationship(cls, request_args, id, related_collection_name, related_resource=None): """ Get a relationship :param request_args: :param id: The 'id' field of the node on the left side of the relationship in the database. The id field must \ be set in the model -- it is n...
[ "def", "get_relationship", "(", "cls", ",", "request_args", ",", "id", ",", "related_collection_name", ",", "related_resource", "=", "None", ")", ":", "try", ":", "included", "=", "request_args", ".", "get", "(", "'include'", ")", ".", "split", "(", "','", ...
Get a relationship :param request_args: :param id: The 'id' field of the node on the left side of the relationship in the database. The id field must \ be set in the model -- it is not the same as the node id :param related_collection_name: The name of the relationship :param re...
[ "Get", "a", "relationship", ":", "param", "request_args", ":", ":", "param", "id", ":", "The", "id", "field", "of", "the", "node", "on", "the", "left", "side", "of", "the", "relationship", "in", "the", "database", ".", "The", "id", "field", "must", "\\...
train
https://github.com/buckmaxwell/neoapi/blob/96c5d83c847d7a12d3d1f17931d85776f5280877/neoapi/serializable_structured_node.py#L860-L888
buckmaxwell/neoapi
neoapi/serializable_structured_node.py
SerializableStructuredNode.create_relationships
def create_relationships(cls, id, related_collection_name, request_json): r""" Used to create relationship(s) between the id node and the nodes identified in the included resource \ identifier objects. :param id: The 'id' field of the node on the left side of the relationship in the dat...
python
def create_relationships(cls, id, related_collection_name, request_json): r""" Used to create relationship(s) between the id node and the nodes identified in the included resource \ identifier objects. :param id: The 'id' field of the node on the left side of the relationship in the dat...
[ "def", "create_relationships", "(", "cls", ",", "id", ",", "related_collection_name", ",", "request_json", ")", ":", "try", ":", "this_resource", "=", "cls", ".", "nodes", ".", "get", "(", "id", "=", "id", ",", "active", "=", "True", ")", "related_collecti...
r""" Used to create relationship(s) between the id node and the nodes identified in the included resource \ identifier objects. :param id: The 'id' field of the node on the left side of the relationship in the database. The id field must \ be set in the model -- it is not the same as t...
[ "r", "Used", "to", "create", "relationship", "(", "s", ")", "between", "the", "id", "node", "and", "the", "nodes", "identified", "in", "the", "included", "resource", "\\", "identifier", "objects", "." ]
train
https://github.com/buckmaxwell/neoapi/blob/96c5d83c847d7a12d3d1f17931d85776f5280877/neoapi/serializable_structured_node.py#L891-L930
buckmaxwell/neoapi
neoapi/serializable_structured_node.py
SerializableStructuredNode.disconnect_relationship
def disconnect_relationship(cls, id, related_collection_name, request_json): """ Disconnect one or more relationship in a collection with cardinality 'Many'. :param id: The 'id' field of the node on the left side of the relationship in the database. The id field must \ be set in the mo...
python
def disconnect_relationship(cls, id, related_collection_name, request_json): """ Disconnect one or more relationship in a collection with cardinality 'Many'. :param id: The 'id' field of the node on the left side of the relationship in the database. The id field must \ be set in the mo...
[ "def", "disconnect_relationship", "(", "cls", ",", "id", ",", "related_collection_name", ",", "request_json", ")", ":", "try", ":", "this_resource", "=", "cls", ".", "nodes", ".", "get", "(", "id", "=", "id", ",", "active", "=", "True", ")", "related_colle...
Disconnect one or more relationship in a collection with cardinality 'Many'. :param id: The 'id' field of the node on the left side of the relationship in the database. The id field must \ be set in the model -- it is not the same as the node id :param related_collection_name: The name of the ...
[ "Disconnect", "one", "or", "more", "relationship", "in", "a", "collection", "with", "cardinality", "Many", "." ]
train
https://github.com/buckmaxwell/neoapi/blob/96c5d83c847d7a12d3d1f17931d85776f5280877/neoapi/serializable_structured_node.py#L933-L963
buckmaxwell/neoapi
neoapi/serializable_structured_node.py
SerializableStructuredNode.delete_relationship
def delete_relationship(cls, id, related_collection_name, related_resource=None): """ Deprecated for version 1.1.0. Please use update_relationship """ try: this_resource = cls.nodes.get(id=id, active=True) if not related_resource: r = this_resourc...
python
def delete_relationship(cls, id, related_collection_name, related_resource=None): """ Deprecated for version 1.1.0. Please use update_relationship """ try: this_resource = cls.nodes.get(id=id, active=True) if not related_resource: r = this_resourc...
[ "def", "delete_relationship", "(", "cls", ",", "id", ",", "related_collection_name", ",", "related_resource", "=", "None", ")", ":", "try", ":", "this_resource", "=", "cls", ".", "nodes", ".", "get", "(", "id", "=", "id", ",", "active", "=", "True", ")",...
Deprecated for version 1.1.0. Please use update_relationship
[ "Deprecated", "for", "version", "1", ".", "1", ".", "0", ".", "Please", "use", "update_relationship" ]
train
https://github.com/buckmaxwell/neoapi/blob/96c5d83c847d7a12d3d1f17931d85776f5280877/neoapi/serializable_structured_node.py#L966-L978
buckmaxwell/neoapi
neoapi/serializable_structured_node.py
SerializableStructuredNode.update_relationship
def update_relationship(cls, id, related_collection_name, request_json): r""" Used to completely replace all the existing relationships with new ones. :param id: The 'id' field of the node on the left side of the relationship in the database. The id field must \ be set in the model -- ...
python
def update_relationship(cls, id, related_collection_name, request_json): r""" Used to completely replace all the existing relationships with new ones. :param id: The 'id' field of the node on the left side of the relationship in the database. The id field must \ be set in the model -- ...
[ "def", "update_relationship", "(", "cls", ",", "id", ",", "related_collection_name", ",", "request_json", ")", ":", "try", ":", "this_resource", "=", "cls", ".", "nodes", ".", "get", "(", "id", "=", "id", ",", "active", "=", "True", ")", "related_collectio...
r""" Used to completely replace all the existing relationships with new ones. :param id: The 'id' field of the node on the left side of the relationship in the database. The id field must \ be set in the model -- it is not the same as the node id :param related_collection_name: The nam...
[ "r", "Used", "to", "completely", "replace", "all", "the", "existing", "relationships", "with", "new", "ones", "." ]
train
https://github.com/buckmaxwell/neoapi/blob/96c5d83c847d7a12d3d1f17931d85776f5280877/neoapi/serializable_structured_node.py#L981-L1043
Fantomas42/mots-vides
mots_vides/factory.py
StopWordFactory.get_stop_words
def get_stop_words(self, language, fail_safe=False): """ Returns a StopWord object initialized with the stop words collection requested by ``language``. If the requested language is not available a StopWordError is raised. If ``fail_safe`` is set to True, an empty StopWord object...
python
def get_stop_words(self, language, fail_safe=False): """ Returns a StopWord object initialized with the stop words collection requested by ``language``. If the requested language is not available a StopWordError is raised. If ``fail_safe`` is set to True, an empty StopWord object...
[ "def", "get_stop_words", "(", "self", ",", "language", ",", "fail_safe", "=", "False", ")", ":", "try", ":", "language", "=", "self", ".", "language_codes", "[", "language", "]", "except", "KeyError", ":", "pass", "collection", "=", "self", ".", "LOADED_LA...
Returns a StopWord object initialized with the stop words collection requested by ``language``. If the requested language is not available a StopWordError is raised. If ``fail_safe`` is set to True, an empty StopWord object is returned.
[ "Returns", "a", "StopWord", "object", "initialized", "with", "the", "stop", "words", "collection", "requested", "by", "language", ".", "If", "the", "requested", "language", "is", "not", "available", "a", "StopWordError", "is", "raised", ".", "If", "fail_safe", ...
train
https://github.com/Fantomas42/mots-vides/blob/eaeccf73bdb415d0c5559ccd74de360b37a2bbac/mots_vides/factory.py#L27-L51
Fantomas42/mots-vides
mots_vides/factory.py
StopWordFactory._get_stop_words
def _get_stop_words(self, language): """ Internal method for getting the stop words collections and raising errors. """ if language not in self.available_languages: raise StopWordError( 'Stop words are not available in "%s".\n' 'If poss...
python
def _get_stop_words(self, language): """ Internal method for getting the stop words collections and raising errors. """ if language not in self.available_languages: raise StopWordError( 'Stop words are not available in "%s".\n' 'If poss...
[ "def", "_get_stop_words", "(", "self", ",", "language", ")", ":", "if", "language", "not", "in", "self", ".", "available_languages", ":", "raise", "StopWordError", "(", "'Stop words are not available in \"%s\".\\n'", "'If possible do a pull request at : '", "'https://github...
Internal method for getting the stop words collections and raising errors.
[ "Internal", "method", "for", "getting", "the", "stop", "words", "collections", "and", "raising", "errors", "." ]
train
https://github.com/Fantomas42/mots-vides/blob/eaeccf73bdb415d0c5559ccd74de360b37a2bbac/mots_vides/factory.py#L53-L71
Fantomas42/mots-vides
mots_vides/factory.py
StopWordFactory.available_languages
def available_languages(self): """ Returns a list of languages providing collection of stop words. """ available_languages = getattr(self, '_available_languages', None) if available_languages: return available_languages try: languages = os.listdir(...
python
def available_languages(self): """ Returns a list of languages providing collection of stop words. """ available_languages = getattr(self, '_available_languages', None) if available_languages: return available_languages try: languages = os.listdir(...
[ "def", "available_languages", "(", "self", ")", ":", "available_languages", "=", "getattr", "(", "self", ",", "'_available_languages'", ",", "None", ")", "if", "available_languages", ":", "return", "available_languages", "try", ":", "languages", "=", "os", ".", ...
Returns a list of languages providing collection of stop words.
[ "Returns", "a", "list", "of", "languages", "providing", "collection", "of", "stop", "words", "." ]
train
https://github.com/Fantomas42/mots-vides/blob/eaeccf73bdb415d0c5559ccd74de360b37a2bbac/mots_vides/factory.py#L74-L88
Fantomas42/mots-vides
mots_vides/factory.py
StopWordFactory.get_collection_filename
def get_collection_filename(self, language): """ Returns the filename containing the stop words collection for a specific language. """ filename = os.path.join(self.data_directory, '%s.txt' % language) return filename
python
def get_collection_filename(self, language): """ Returns the filename containing the stop words collection for a specific language. """ filename = os.path.join(self.data_directory, '%s.txt' % language) return filename
[ "def", "get_collection_filename", "(", "self", ",", "language", ")", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "data_directory", ",", "'%s.txt'", "%", "language", ")", "return", "filename" ]
Returns the filename containing the stop words collection for a specific language.
[ "Returns", "the", "filename", "containing", "the", "stop", "words", "collection", "for", "a", "specific", "language", "." ]
train
https://github.com/Fantomas42/mots-vides/blob/eaeccf73bdb415d0c5559ccd74de360b37a2bbac/mots_vides/factory.py#L94-L100
Fantomas42/mots-vides
mots_vides/factory.py
StopWordFactory.read_collection
def read_collection(self, filename): """ Reads and returns a collection of stop words into a file. """ with open(filename, 'rb') as fd: lines = fd.read().decode('utf-8-sig').splitlines() collection = list(filter(bool, [line.strip() for line in lines])) return ...
python
def read_collection(self, filename): """ Reads and returns a collection of stop words into a file. """ with open(filename, 'rb') as fd: lines = fd.read().decode('utf-8-sig').splitlines() collection = list(filter(bool, [line.strip() for line in lines])) return ...
[ "def", "read_collection", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "fd", ":", "lines", "=", "fd", ".", "read", "(", ")", ".", "decode", "(", "'utf-8-sig'", ")", ".", "splitlines", "(", ")", "c...
Reads and returns a collection of stop words into a file.
[ "Reads", "and", "returns", "a", "collection", "of", "stop", "words", "into", "a", "file", "." ]
train
https://github.com/Fantomas42/mots-vides/blob/eaeccf73bdb415d0c5559ccd74de360b37a2bbac/mots_vides/factory.py#L102-L109
Fantomas42/mots-vides
mots_vides/factory.py
StopWordFactory.write_collection
def write_collection(self, filename, collection): """ Writes a collection of stop words into a file. """ collection = sorted(list(collection)) with open(filename, 'wb+') as fd: fd.truncate() fd.write('\n'.join(collection).encode('utf-8'))
python
def write_collection(self, filename, collection): """ Writes a collection of stop words into a file. """ collection = sorted(list(collection)) with open(filename, 'wb+') as fd: fd.truncate() fd.write('\n'.join(collection).encode('utf-8'))
[ "def", "write_collection", "(", "self", ",", "filename", ",", "collection", ")", ":", "collection", "=", "sorted", "(", "list", "(", "collection", ")", ")", "with", "open", "(", "filename", ",", "'wb+'", ")", "as", "fd", ":", "fd", ".", "truncate", "("...
Writes a collection of stop words into a file.
[ "Writes", "a", "collection", "of", "stop", "words", "into", "a", "file", "." ]
train
https://github.com/Fantomas42/mots-vides/blob/eaeccf73bdb415d0c5559ccd74de360b37a2bbac/mots_vides/factory.py#L111-L118
sveetch/boussole
boussole/cli/startproject.py
startproject_command
def startproject_command(context, basedir, sourcedir, targetdir, backend, config): """ Create a new Sass project This will prompt you to define your project configuration in a settings file then create needed directory structure. Arguments 'basedir', 'config', 'sourcedir',...
python
def startproject_command(context, basedir, sourcedir, targetdir, backend, config): """ Create a new Sass project This will prompt you to define your project configuration in a settings file then create needed directory structure. Arguments 'basedir', 'config', 'sourcedir',...
[ "def", "startproject_command", "(", "context", ",", "basedir", ",", "sourcedir", ",", "targetdir", ",", "backend", ",", "config", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "\"boussole\"", ")", "starter", "=", "ProjectStarter", "(", "backend_na...
Create a new Sass project This will prompt you to define your project configuration in a settings file then create needed directory structure. Arguments 'basedir', 'config', 'sourcedir', 'targetdir' can not be empty. 'backend' argument is optionnal, its value can be "json" or "yaml" and its defau...
[ "Create", "a", "new", "Sass", "project" ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/cli/startproject.py#L36-L80
zatosource/zato-redis-paginator
src/zato/redis_paginator/examples.py
list_example
def list_example(): """ Example list pagination. """ from uuid import uuid4 from redis import StrictRedis from zato.redis_paginator import ListPaginator conn = StrictRedis() key = 'paginator:{}'.format(uuid4().hex) for x in range(1, 18): conn.rpush(key, x) ...
python
def list_example(): """ Example list pagination. """ from uuid import uuid4 from redis import StrictRedis from zato.redis_paginator import ListPaginator conn = StrictRedis() key = 'paginator:{}'.format(uuid4().hex) for x in range(1, 18): conn.rpush(key, x) ...
[ "def", "list_example", "(", ")", ":", "from", "uuid", "import", "uuid4", "from", "redis", "import", "StrictRedis", "from", "zato", ".", "redis_paginator", "import", "ListPaginator", "conn", "=", "StrictRedis", "(", ")", "key", "=", "'paginator:{}'", ".", "form...
Example list pagination.
[ "Example", "list", "pagination", "." ]
train
https://github.com/zatosource/zato-redis-paginator/blob/42821f71307f8717315b543d55b473abd2db44de/src/zato/redis_paginator/examples.py#L17-L40
zatosource/zato-redis-paginator
src/zato/redis_paginator/examples.py
zset_example
def zset_example(): """ Example sorted set pagination. """ from uuid import uuid4 from redis import StrictRedis from zato.redis_paginator import ZSetPaginator conn = StrictRedis() key = 'paginator:{}'.format(uuid4().hex) # 97-114 is 'a' to 'r' in ASCII for x in range(1, 18)...
python
def zset_example(): """ Example sorted set pagination. """ from uuid import uuid4 from redis import StrictRedis from zato.redis_paginator import ZSetPaginator conn = StrictRedis() key = 'paginator:{}'.format(uuid4().hex) # 97-114 is 'a' to 'r' in ASCII for x in range(1, 18)...
[ "def", "zset_example", "(", ")", ":", "from", "uuid", "import", "uuid4", "from", "redis", "import", "StrictRedis", "from", "zato", ".", "redis_paginator", "import", "ZSetPaginator", "conn", "=", "StrictRedis", "(", ")", "key", "=", "'paginator:{}'", ".", "form...
Example sorted set pagination.
[ "Example", "sorted", "set", "pagination", "." ]
train
https://github.com/zatosource/zato-redis-paginator/blob/42821f71307f8717315b543d55b473abd2db44de/src/zato/redis_paginator/examples.py#L42-L66
relwell/corenlp-xml-lib
corenlp_xml/dependencies.py
DependencyNode.load
def load(cls, graph, element): """ Instantiates the node in the graph if it's not already stored in the graph :param graph: The dependency graph this node is a member of :type graph: corenlp_xml.dependencies.DependencyGraph :param element: The lxml element wrapping the node ...
python
def load(cls, graph, element): """ Instantiates the node in the graph if it's not already stored in the graph :param graph: The dependency graph this node is a member of :type graph: corenlp_xml.dependencies.DependencyGraph :param element: The lxml element wrapping the node ...
[ "def", "load", "(", "cls", ",", "graph", ",", "element", ")", ":", "node", "=", "graph", ".", "get_node_by_idx", "(", "id", "(", "element", ".", "get", "(", "\"idx\"", ")", ")", ")", "if", "node", "is", "None", ":", "node", "=", "cls", "(", "grap...
Instantiates the node in the graph if it's not already stored in the graph :param graph: The dependency graph this node is a member of :type graph: corenlp_xml.dependencies.DependencyGraph :param element: The lxml element wrapping the node :type element: lxml.ElementBase
[ "Instantiates", "the", "node", "in", "the", "graph", "if", "it", "s", "not", "already", "stored", "in", "the", "graph" ]
train
https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/dependencies.py#L93-L107
relwell/corenlp-xml-lib
corenlp_xml/dependencies.py
DependencyNode.governor
def governor(self, dep_type, node): """ Registers a node as governing this node :param dep_type: The dependency type :type dep_type: str :param node: :return: self, provides fluent interface :rtype: corenlp_xml.dependencies.DependencyNode """ se...
python
def governor(self, dep_type, node): """ Registers a node as governing this node :param dep_type: The dependency type :type dep_type: str :param node: :return: self, provides fluent interface :rtype: corenlp_xml.dependencies.DependencyNode """ se...
[ "def", "governor", "(", "self", ",", "dep_type", ",", "node", ")", ":", "self", ".", "_governors", "[", "dep_type", "]", "=", "self", ".", "_governors", ".", "get", "(", "dep_type", ",", "[", "]", ")", "+", "[", "node", "]", "return", "self" ]
Registers a node as governing this node :param dep_type: The dependency type :type dep_type: str :param node: :return: self, provides fluent interface :rtype: corenlp_xml.dependencies.DependencyNode
[ "Registers", "a", "node", "as", "governing", "this", "node" ]
train
https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/dependencies.py#L155-L168
relwell/corenlp-xml-lib
corenlp_xml/dependencies.py
DependencyNode.dependent
def dependent(self, dep_type, node): """ Registers a node as dependent on this node :param dep_type: The dependency type :type dep_type: str :param node: The node to be registered as a dependent :type node: corenlp_xml.dependencies.DependencyNode :return: self, ...
python
def dependent(self, dep_type, node): """ Registers a node as dependent on this node :param dep_type: The dependency type :type dep_type: str :param node: The node to be registered as a dependent :type node: corenlp_xml.dependencies.DependencyNode :return: self, ...
[ "def", "dependent", "(", "self", ",", "dep_type", ",", "node", ")", ":", "self", ".", "_dependents", "[", "dep_type", "]", "=", "self", ".", "_dependents", ".", "get", "(", "dep_type", ",", "[", "]", ")", "+", "[", "node", "]", "return", "self" ]
Registers a node as dependent on this node :param dep_type: The dependency type :type dep_type: str :param node: The node to be registered as a dependent :type node: corenlp_xml.dependencies.DependencyNode :return: self, provides fluent interface :rtype: corenlp_xml.dep...
[ "Registers", "a", "node", "as", "dependent", "on", "this", "node" ]
train
https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/dependencies.py#L170-L184
relwell/corenlp-xml-lib
corenlp_xml/dependencies.py
DependencyLink.governor
def governor(self): """ Accesses the governor node :getter: Returns the Governor node :type: corenlp_xml.dependencies.DependencyNode """ if self._governor is None: governors = self._element.xpath('governor') if len(governors) > 0: ...
python
def governor(self): """ Accesses the governor node :getter: Returns the Governor node :type: corenlp_xml.dependencies.DependencyNode """ if self._governor is None: governors = self._element.xpath('governor') if len(governors) > 0: ...
[ "def", "governor", "(", "self", ")", ":", "if", "self", ".", "_governor", "is", "None", ":", "governors", "=", "self", ".", "_element", ".", "xpath", "(", "'governor'", ")", "if", "len", "(", "governors", ")", ">", "0", ":", "self", ".", "_governor",...
Accesses the governor node :getter: Returns the Governor node :type: corenlp_xml.dependencies.DependencyNode
[ "Accesses", "the", "governor", "node" ]
train
https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/dependencies.py#L214-L226
relwell/corenlp-xml-lib
corenlp_xml/dependencies.py
DependencyLink.dependent
def dependent(self): """ Accesses the dependent node :getter: returns the Dependent node :type: corenlp_xml.dependencies.DependencyNode """ if self._dependent is None: dependents = self._element.xpath('dependent') if len(dependents) > 0: ...
python
def dependent(self): """ Accesses the dependent node :getter: returns the Dependent node :type: corenlp_xml.dependencies.DependencyNode """ if self._dependent is None: dependents = self._element.xpath('dependent') if len(dependents) > 0: ...
[ "def", "dependent", "(", "self", ")", ":", "if", "self", ".", "_dependent", "is", "None", ":", "dependents", "=", "self", ".", "_element", ".", "xpath", "(", "'dependent'", ")", "if", "len", "(", "dependents", ")", ">", "0", ":", "self", ".", "_depen...
Accesses the dependent node :getter: returns the Dependent node :type: corenlp_xml.dependencies.DependencyNode
[ "Accesses", "the", "dependent", "node" ]
train
https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/dependencies.py#L229-L241
sveetch/boussole
boussole/parser.py
ScssImportsParser.strip_quotes
def strip_quotes(self, content): """ Unquote given rule. Args: content (str): An import rule. Raises: InvalidImportRule: Raise exception if the rule is badly quoted (not started or not ended quotes). Returns: string: The given ru...
python
def strip_quotes(self, content): """ Unquote given rule. Args: content (str): An import rule. Raises: InvalidImportRule: Raise exception if the rule is badly quoted (not started or not ended quotes). Returns: string: The given ru...
[ "def", "strip_quotes", "(", "self", ",", "content", ")", ":", "error_msg", "=", "\"Following rule is badly quoted: {}\"", "if", "(", "content", ".", "startswith", "(", "'\"'", ")", "and", "content", ".", "endswith", "(", "'\"'", ")", ")", "or", "(", "content...
Unquote given rule. Args: content (str): An import rule. Raises: InvalidImportRule: Raise exception if the rule is badly quoted (not started or not ended quotes). Returns: string: The given rule unquoted.
[ "Unquote", "given", "rule", "." ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/parser.py#L44-L71
sveetch/boussole
boussole/parser.py
ScssImportsParser.flatten_rules
def flatten_rules(self, declarations): """ Flatten returned import rules from regex. Because import rules can contains multiple items in the same rule (called multiline import rule), the regex ``REGEX_IMPORT_RULE`` return a list of unquoted items for each rule. Args: ...
python
def flatten_rules(self, declarations): """ Flatten returned import rules from regex. Because import rules can contains multiple items in the same rule (called multiline import rule), the regex ``REGEX_IMPORT_RULE`` return a list of unquoted items for each rule. Args: ...
[ "def", "flatten_rules", "(", "self", ",", "declarations", ")", ":", "rules", "=", "[", "]", "for", "protocole", ",", "paths", "in", "declarations", ":", "# If there is a protocole (like 'url), drop it", "if", "protocole", ":", "continue", "# Unquote and possibly split...
Flatten returned import rules from regex. Because import rules can contains multiple items in the same rule (called multiline import rule), the regex ``REGEX_IMPORT_RULE`` return a list of unquoted items for each rule. Args: declarations (list): A SCSS source. Retu...
[ "Flatten", "returned", "import", "rules", "from", "regex", "." ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/parser.py#L94-L118
sveetch/boussole
boussole/parser.py
ScssImportsParser.parse
def parse(self, content): """ Parse a stylesheet document with a regex (``REGEX_IMPORT_RULE``) to extract all import rules and return them. Args: content (str): A SCSS source. Returns: list: Finded paths in import rules. """ # Remove all ...
python
def parse(self, content): """ Parse a stylesheet document with a regex (``REGEX_IMPORT_RULE``) to extract all import rules and return them. Args: content (str): A SCSS source. Returns: list: Finded paths in import rules. """ # Remove all ...
[ "def", "parse", "(", "self", ",", "content", ")", ":", "# Remove all comments before searching for import rules, to not catch", "# commented breaked import rules", "declarations", "=", "self", ".", "REGEX_IMPORT_RULE", ".", "findall", "(", "self", ".", "remove_comments", "(...
Parse a stylesheet document with a regex (``REGEX_IMPORT_RULE``) to extract all import rules and return them. Args: content (str): A SCSS source. Returns: list: Finded paths in import rules.
[ "Parse", "a", "stylesheet", "document", "with", "a", "regex", "(", "REGEX_IMPORT_RULE", ")", "to", "extract", "all", "import", "rules", "and", "return", "them", "." ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/parser.py#L120-L136
isambard-uob/ampal
src/ampal/naccess.py
naccess_available
def naccess_available(): """True if naccess is available on the path.""" available = False try: subprocess.check_output(['naccess'], stderr=subprocess.DEVNULL) except subprocess.CalledProcessError: available = True except FileNotFoundError: print("naccess has not been found o...
python
def naccess_available(): """True if naccess is available on the path.""" available = False try: subprocess.check_output(['naccess'], stderr=subprocess.DEVNULL) except subprocess.CalledProcessError: available = True except FileNotFoundError: print("naccess has not been found o...
[ "def", "naccess_available", "(", ")", ":", "available", "=", "False", "try", ":", "subprocess", ".", "check_output", "(", "[", "'naccess'", "]", ",", "stderr", "=", "subprocess", ".", "DEVNULL", ")", "except", "subprocess", ".", "CalledProcessError", ":", "a...
True if naccess is available on the path.
[ "True", "if", "naccess", "is", "available", "on", "the", "path", "." ]
train
https://github.com/isambard-uob/ampal/blob/906e2afacb435ffb129b381f262ff8e7bfb324c5/src/ampal/naccess.py#L8-L19
isambard-uob/ampal
src/ampal/naccess.py
run_naccess
def run_naccess(pdb, mode, path=True, include_hetatms=False, outfile=None, path_to_ex=None): """Uses naccess to run surface accessibility calculations. Notes ----- Requires the naccess program, with a path to its executable provided in global_settings. For information on the Naccess...
python
def run_naccess(pdb, mode, path=True, include_hetatms=False, outfile=None, path_to_ex=None): """Uses naccess to run surface accessibility calculations. Notes ----- Requires the naccess program, with a path to its executable provided in global_settings. For information on the Naccess...
[ "def", "run_naccess", "(", "pdb", ",", "mode", ",", "path", "=", "True", ",", "include_hetatms", "=", "False", ",", "outfile", "=", "None", ",", "path_to_ex", "=", "None", ")", ":", "if", "mode", "not", "in", "[", "'asa'", ",", "'rsa'", ",", "'log'",...
Uses naccess to run surface accessibility calculations. Notes ----- Requires the naccess program, with a path to its executable provided in global_settings. For information on the Naccess program, see: http://www.bioinf.manchester.ac.uk/naccess/ This includes information on the licensing, which...
[ "Uses", "naccess", "to", "run", "surface", "accessibility", "calculations", "." ]
train
https://github.com/isambard-uob/ampal/blob/906e2afacb435ffb129b381f262ff8e7bfb324c5/src/ampal/naccess.py#L22-L93
isambard-uob/ampal
src/ampal/naccess.py
extract_residue_accessibility
def extract_residue_accessibility(in_rsa, path=True, get_total=False): """Parses rsa file for solvent accessibility for each residue. Parameters ---------- in_rsa : str Path to naccess rsa file path : bool Indicates if in_rsa is a path or a string get_total : bool Indica...
python
def extract_residue_accessibility(in_rsa, path=True, get_total=False): """Parses rsa file for solvent accessibility for each residue. Parameters ---------- in_rsa : str Path to naccess rsa file path : bool Indicates if in_rsa is a path or a string get_total : bool Indica...
[ "def", "extract_residue_accessibility", "(", "in_rsa", ",", "path", "=", "True", ",", "get_total", "=", "False", ")", ":", "if", "path", ":", "with", "open", "(", "in_rsa", ",", "'r'", ")", "as", "inf", ":", "rsa", "=", "inf", ".", "read", "(", ")", ...
Parses rsa file for solvent accessibility for each residue. Parameters ---------- in_rsa : str Path to naccess rsa file path : bool Indicates if in_rsa is a path or a string get_total : bool Indicates if the total accessibility from the file needs to be extracted. Co...
[ "Parses", "rsa", "file", "for", "solvent", "accessibility", "for", "each", "residue", "." ]
train
https://github.com/isambard-uob/ampal/blob/906e2afacb435ffb129b381f262ff8e7bfb324c5/src/ampal/naccess.py#L127-L165
anybox/selenium-configurator
selenium_configurator/driver.py
Driver.selenium
def selenium(self): """Get the instance of webdriver, it starts the browser if the webdriver is not yet instantied :return: a `selenium instance <http://selenium-python.readthedocs.org/ api.html#module-selenium.webdriver.remote.webdriver>` """ if not self._web_driver: ...
python
def selenium(self): """Get the instance of webdriver, it starts the browser if the webdriver is not yet instantied :return: a `selenium instance <http://selenium-python.readthedocs.org/ api.html#module-selenium.webdriver.remote.webdriver>` """ if not self._web_driver: ...
[ "def", "selenium", "(", "self", ")", ":", "if", "not", "self", ".", "_web_driver", ":", "self", ".", "_web_driver", "=", "self", ".", "_start_driver", "(", ")", "return", "self", ".", "_web_driver" ]
Get the instance of webdriver, it starts the browser if the webdriver is not yet instantied :return: a `selenium instance <http://selenium-python.readthedocs.org/ api.html#module-selenium.webdriver.remote.webdriver>`
[ "Get", "the", "instance", "of", "webdriver", "it", "starts", "the", "browser", "if", "the", "webdriver", "is", "not", "yet", "instantied" ]
train
https://github.com/anybox/selenium-configurator/blob/6cd83d77583f52e86353b516f9bc235e853b7e33/selenium_configurator/driver.py#L84-L93
datalib/StatsCounter
statscounter/statscounter.py
StatsCounter.normalize
def normalize(self): """ Sum the values in a Counter, then create a new Counter where each new value (while keeping the original key) is equal to the original value divided by sum of all the original values (this is sometimes referred to as the normalization constant). https://en.wikipedia.org/wiki/No...
python
def normalize(self): """ Sum the values in a Counter, then create a new Counter where each new value (while keeping the original key) is equal to the original value divided by sum of all the original values (this is sometimes referred to as the normalization constant). https://en.wikipedia.org/wiki/No...
[ "def", "normalize", "(", "self", ")", ":", "total", "=", "sum", "(", "self", ".", "values", "(", ")", ")", "stats", "=", "{", "k", ":", "(", "v", "/", "float", "(", "total", ")", ")", "for", "k", ",", "v", "in", "self", ".", "items", "(", "...
Sum the values in a Counter, then create a new Counter where each new value (while keeping the original key) is equal to the original value divided by sum of all the original values (this is sometimes referred to as the normalization constant). https://en.wikipedia.org/wiki/Normalization_(statistics)
[ "Sum", "the", "values", "in", "a", "Counter", "then", "create", "a", "new", "Counter", "where", "each", "new", "value", "(", "while", "keeping", "the", "original", "key", ")", "is", "equal", "to", "the", "original", "value", "divided", "by", "sum", "of",...
train
https://github.com/datalib/StatsCounter/blob/5386c967808bbe451025af1d550f060cd7f86669/statscounter/statscounter.py#L94-L105
datalib/StatsCounter
statscounter/statscounter.py
StatsCounter.get_weighted_random_value
def get_weighted_random_value(self): """ This will generate a value by creating a cumulative distribution, and a random number, and selecting the value who's cumulative distribution interval contains the generated random number. For example, if there's 0.7 chance of generating the letter "a" and 0.3 c...
python
def get_weighted_random_value(self): """ This will generate a value by creating a cumulative distribution, and a random number, and selecting the value who's cumulative distribution interval contains the generated random number. For example, if there's 0.7 chance of generating the letter "a" and 0.3 c...
[ "def", "get_weighted_random_value", "(", "self", ")", ":", "from", "bisect", "import", "bisect", "from", "random", "import", "random", "#http://stackoverflow.com/questions/4437250/choose-list-variable-given-probability-of-each-variable", "total", "=", "sum", "(", "self", ".",...
This will generate a value by creating a cumulative distribution, and a random number, and selecting the value who's cumulative distribution interval contains the generated random number. For example, if there's 0.7 chance of generating the letter "a" and 0.3 chance of generating the letter "b", then if y...
[ "This", "will", "generate", "a", "value", "by", "creating", "a", "cumulative", "distribution", "and", "a", "random", "number", "and", "selecting", "the", "value", "who", "s", "cumulative", "distribution", "interval", "contains", "the", "generated", "random", "nu...
train
https://github.com/datalib/StatsCounter/blob/5386c967808bbe451025af1d550f060cd7f86669/statscounter/statscounter.py#L107-L133
sveetch/boussole
boussole/finder.py
paths_by_depth
def paths_by_depth(paths): """Sort list of paths by number of directories in it .. todo:: check if a final '/' is consistently given or ommitted. :param iterable paths: iterable containing paths (str) :rtype: list """ return sorted( paths, key=lambda path: path...
python
def paths_by_depth(paths): """Sort list of paths by number of directories in it .. todo:: check if a final '/' is consistently given or ommitted. :param iterable paths: iterable containing paths (str) :rtype: list """ return sorted( paths, key=lambda path: path...
[ "def", "paths_by_depth", "(", "paths", ")", ":", "return", "sorted", "(", "paths", ",", "key", "=", "lambda", "path", ":", "path", ".", "count", "(", "os", ".", "path", ".", "sep", ")", ",", "reverse", "=", "True", ")" ]
Sort list of paths by number of directories in it .. todo:: check if a final '/' is consistently given or ommitted. :param iterable paths: iterable containing paths (str) :rtype: list
[ "Sort", "list", "of", "paths", "by", "number", "of", "directories", "in", "it" ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/finder.py#L20-L34
sveetch/boussole
boussole/finder.py
ScssFinder.get_relative_from_paths
def get_relative_from_paths(self, filepath, paths): """ Find the relative filepath from the most relevant multiple paths. This is somewhat like a ``os.path.relpath(path[, start])`` but where ``start`` is a list. The most relevant item from ``paths`` will be used to apply the rel...
python
def get_relative_from_paths(self, filepath, paths): """ Find the relative filepath from the most relevant multiple paths. This is somewhat like a ``os.path.relpath(path[, start])`` but where ``start`` is a list. The most relevant item from ``paths`` will be used to apply the rel...
[ "def", "get_relative_from_paths", "(", "self", ",", "filepath", ",", "paths", ")", ":", "for", "systempath", "in", "paths_by_depth", "(", "paths", ")", ":", "if", "filepath", ".", "startswith", "(", "systempath", ")", ":", "return", "os", ".", "path", ".",...
Find the relative filepath from the most relevant multiple paths. This is somewhat like a ``os.path.relpath(path[, start])`` but where ``start`` is a list. The most relevant item from ``paths`` will be used to apply the relative transform. Args: filepath (str): Path to tran...
[ "Find", "the", "relative", "filepath", "from", "the", "most", "relevant", "multiple", "paths", "." ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/finder.py#L47-L75
sveetch/boussole
boussole/finder.py
ScssFinder.is_partial
def is_partial(self, filepath): """ Check if file is a Sass partial source (see `Sass partials Reference`_). Args: filepath (str): A file path. Can be absolute, relative or just a filename. Returns: bool: True if file is a partial source, els...
python
def is_partial(self, filepath): """ Check if file is a Sass partial source (see `Sass partials Reference`_). Args: filepath (str): A file path. Can be absolute, relative or just a filename. Returns: bool: True if file is a partial source, els...
[ "def", "is_partial", "(", "self", ",", "filepath", ")", ":", "path", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "filepath", ")", "return", "filename", ".", "startswith", "(", "'_'", ")" ]
Check if file is a Sass partial source (see `Sass partials Reference`_). Args: filepath (str): A file path. Can be absolute, relative or just a filename. Returns: bool: True if file is a partial source, else False.
[ "Check", "if", "file", "is", "a", "Sass", "partial", "source", "(", "see", "Sass", "partials", "Reference", "_", ")", "." ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/finder.py#L77-L90
sveetch/boussole
boussole/finder.py
ScssFinder.is_allowed
def is_allowed(self, filepath, excludes=[]): """ Check from exclude patterns if a relative filepath is allowed Args: filepath (str): A relative file path. (exclude patterns are allways based from the source directory). Keyword Arguments: excludes...
python
def is_allowed(self, filepath, excludes=[]): """ Check from exclude patterns if a relative filepath is allowed Args: filepath (str): A relative file path. (exclude patterns are allways based from the source directory). Keyword Arguments: excludes...
[ "def", "is_allowed", "(", "self", ",", "filepath", ",", "excludes", "=", "[", "]", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "filepath", ")", ":", "raise", "FinderException", "(", "\"'Finder.is_allowed()' only accept relative\"", "\" filepath\"", "...
Check from exclude patterns if a relative filepath is allowed Args: filepath (str): A relative file path. (exclude patterns are allways based from the source directory). Keyword Arguments: excludes (list): A list of excluding (glob) patterns. If filepath ...
[ "Check", "from", "exclude", "patterns", "if", "a", "relative", "filepath", "is", "allowed" ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/finder.py#L92-L118
sveetch/boussole
boussole/finder.py
ScssFinder.match_conditions
def match_conditions(self, filepath, sourcedir=None, nopartial=True, exclude_patterns=[], excluded_libdirs=[]): """ Find if a filepath match all required conditions. Available conditions are (in order): * Is allowed file extension; * Is a partial source...
python
def match_conditions(self, filepath, sourcedir=None, nopartial=True, exclude_patterns=[], excluded_libdirs=[]): """ Find if a filepath match all required conditions. Available conditions are (in order): * Is allowed file extension; * Is a partial source...
[ "def", "match_conditions", "(", "self", ",", "filepath", ",", "sourcedir", "=", "None", ",", "nopartial", "=", "True", ",", "exclude_patterns", "=", "[", "]", ",", "excluded_libdirs", "=", "[", "]", ")", ":", "# Ensure libdirs ends with / to avoid missmatching wit...
Find if a filepath match all required conditions. Available conditions are (in order): * Is allowed file extension; * Is a partial source; * Is from an excluded directory; * Is matching an exclude pattern; Args: filepath (str): Absolute filepath to match ag...
[ "Find", "if", "a", "filepath", "match", "all", "required", "conditions", "." ]
train
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/finder.py#L120-L181