repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
MartinThoma/geocodertools
geocodertools/reverse.py
get_cartesian
def get_cartesian(lat, lon): """ the x-axis goes through long,lat (0,0), so longitude 0 meets the equator; the y-axis goes through (0,90); and the z-axis goes through the poles. In other words: * (0, 0, 0) is the center of earth * (0, 0, R) is the north pole * (0, 0, -R) is the south po...
python
def get_cartesian(lat, lon): """ the x-axis goes through long,lat (0,0), so longitude 0 meets the equator; the y-axis goes through (0,90); and the z-axis goes through the poles. In other words: * (0, 0, 0) is the center of earth * (0, 0, R) is the north pole * (0, 0, -R) is the south po...
[ "def", "get_cartesian", "(", "lat", ",", "lon", ")", ":", "R", "=", "6371000.0", "# metres", "x", "=", "R", "*", "math", ".", "cos", "(", "lat", ")", "*", "math", ".", "cos", "(", "lon", ")", "y", "=", "R", "*", "math", ".", "cos", "(", "lat"...
the x-axis goes through long,lat (0,0), so longitude 0 meets the equator; the y-axis goes through (0,90); and the z-axis goes through the poles. In other words: * (0, 0, 0) is the center of earth * (0, 0, R) is the north pole * (0, 0, -R) is the south pole * (R, 0, 0) is somewhere in africa...
[ "the", "x", "-", "axis", "goes", "through", "long", "lat", "(", "0", "0", ")", "so", "longitude", "0", "meets", "the", "equator", ";", "the", "y", "-", "axis", "goes", "through", "(", "0", "90", ")", ";", "and", "the", "z", "-", "axis", "goes", ...
train
https://github.com/MartinThoma/geocodertools/blob/d590dbde7b03497df713bd9ae17d739319e87096/geocodertools/reverse.py#L75-L94
MartinThoma/geocodertools
geocodertools/reverse.py
find_closest
def find_closest(db, pos): """Find the closest point in db to pos. :returns: Closest dataset as well as the distance in meters. """ def get_dist(d1, d2): """Get distance between d1 and d2 in meters.""" lat1, lon1 = d1['latitude'], d1['longitude'] lat2, lon2 = d2['latitude'], d2['...
python
def find_closest(db, pos): """Find the closest point in db to pos. :returns: Closest dataset as well as the distance in meters. """ def get_dist(d1, d2): """Get distance between d1 and d2 in meters.""" lat1, lon1 = d1['latitude'], d1['longitude'] lat2, lon2 = d2['latitude'], d2['...
[ "def", "find_closest", "(", "db", ",", "pos", ")", ":", "def", "get_dist", "(", "d1", ",", "d2", ")", ":", "\"\"\"Get distance between d1 and d2 in meters.\"\"\"", "lat1", ",", "lon1", "=", "d1", "[", "'latitude'", "]", ",", "d1", "[", "'longitude'", "]", ...
Find the closest point in db to pos. :returns: Closest dataset as well as the distance in meters.
[ "Find", "the", "closest", "point", "in", "db", "to", "pos", ".", ":", "returns", ":", "Closest", "dataset", "as", "well", "as", "the", "distance", "in", "meters", "." ]
train
https://github.com/MartinThoma/geocodertools/blob/d590dbde7b03497df713bd9ae17d739319e87096/geocodertools/reverse.py#L97-L124
MartinThoma/geocodertools
geocodertools/reverse.py
get_parser
def get_parser(): """Return the parser object for this script.""" from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter from argparse import ArgumentTypeError def latitude(x): x = float(x) if x < -90.0 or x > 90.0: raise ArgumentTypeError("%r not in range [-90.0...
python
def get_parser(): """Return the parser object for this script.""" from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter from argparse import ArgumentTypeError def latitude(x): x = float(x) if x < -90.0 or x > 90.0: raise ArgumentTypeError("%r not in range [-90.0...
[ "def", "get_parser", "(", ")", ":", "from", "argparse", "import", "ArgumentParser", ",", "ArgumentDefaultsHelpFormatter", "from", "argparse", "import", "ArgumentTypeError", "def", "latitude", "(", "x", ")", ":", "x", "=", "float", "(", "x", ")", "if", "x", "...
Return the parser object for this script.
[ "Return", "the", "parser", "object", "for", "this", "script", "." ]
train
https://github.com/MartinThoma/geocodertools/blob/d590dbde7b03497df713bd9ae17d739319e87096/geocodertools/reverse.py#L159-L192
MartinThoma/geocodertools
geocodertools/reverse.py
main
def main(pos, bobj=None): """ :param pos: A dictionary with {'latitude': 8.12, 'longitude': 42.6} :param bobj: An object which has a 'get' method and returns a dictionary. """ city, distance = get_city(pos, bobj) city = get_city_from_file(city['linenr']) print("The city '%s' is about %0.2fkm...
python
def main(pos, bobj=None): """ :param pos: A dictionary with {'latitude': 8.12, 'longitude': 42.6} :param bobj: An object which has a 'get' method and returns a dictionary. """ city, distance = get_city(pos, bobj) city = get_city_from_file(city['linenr']) print("The city '%s' is about %0.2fkm...
[ "def", "main", "(", "pos", ",", "bobj", "=", "None", ")", ":", "city", ",", "distance", "=", "get_city", "(", "pos", ",", "bobj", ")", "city", "=", "get_city_from_file", "(", "city", "[", "'linenr'", "]", ")", "print", "(", "\"The city '%s' is about %0.2...
:param pos: A dictionary with {'latitude': 8.12, 'longitude': 42.6} :param bobj: An object which has a 'get' method and returns a dictionary.
[ ":", "param", "pos", ":", "A", "dictionary", "with", "{", "latitude", ":", "8", ".", "12", "longitude", ":", "42", ".", "6", "}", ":", "param", "bobj", ":", "An", "object", "which", "has", "a", "get", "method", "and", "returns", "a", "dictionary", ...
train
https://github.com/MartinThoma/geocodertools/blob/d590dbde7b03497df713bd9ae17d739319e87096/geocodertools/reverse.py#L230-L240
MartinThoma/geocodertools
geocodertools/reverse.py
BinClassifier.get
def get(self, pos): """Get the closest dataset.""" latitude = int(round(pos['latitude'])) search_set = self.bins[latitude] i = 1 if latitude - i >= -90: search_set += self.bins[latitude-i] if latitude + i <= 90: search_set += self.bins[latitude+i] ...
python
def get(self, pos): """Get the closest dataset.""" latitude = int(round(pos['latitude'])) search_set = self.bins[latitude] i = 1 if latitude - i >= -90: search_set += self.bins[latitude-i] if latitude + i <= 90: search_set += self.bins[latitude+i] ...
[ "def", "get", "(", "self", ",", "pos", ")", ":", "latitude", "=", "int", "(", "round", "(", "pos", "[", "'latitude'", "]", ")", ")", "search_set", "=", "self", ".", "bins", "[", "latitude", "]", "i", "=", "1", "if", "latitude", "-", "i", ">=", ...
Get the closest dataset.
[ "Get", "the", "closest", "dataset", "." ]
train
https://github.com/MartinThoma/geocodertools/blob/d590dbde7b03497df713bd9ae17d739319e87096/geocodertools/reverse.py#L141-L156
westerncapelabs/django-snappy-vumi-bouncer
snappybouncer/api.py
urlencodeSerializer.from_urlencode
def from_urlencode(self, data, options=None): """ handles basic formencoded url posts """ qs = dict((k, v if len(v) > 1 else v[0]) for k, v in urlparse.parse_qs(data).iteritems()) return qs
python
def from_urlencode(self, data, options=None): """ handles basic formencoded url posts """ qs = dict((k, v if len(v) > 1 else v[0]) for k, v in urlparse.parse_qs(data).iteritems()) return qs
[ "def", "from_urlencode", "(", "self", ",", "data", ",", "options", "=", "None", ")", ":", "qs", "=", "dict", "(", "(", "k", ",", "v", "if", "len", "(", "v", ")", ">", "1", "else", "v", "[", "0", "]", ")", "for", "k", ",", "v", "in", "urlpar...
handles basic formencoded url posts
[ "handles", "basic", "formencoded", "url", "posts" ]
train
https://github.com/westerncapelabs/django-snappy-vumi-bouncer/blob/5750827020aa83f0f5eecee87a2fe8f19dfaac16/snappybouncer/api.py#L94-L98
Jayin/ETipsService
service/lifeService.py
LifeService._get_electricity_info_html
def _get_electricity_info_html( apart_id, meter_room): """get html :param apart_id: 栋数 :param meter_room: 宿舍号 """ if apart.get(apart_id) is None: raise KeyError('not support the apart_id= ' + apart_id) post_data = { 'action': 'search', ...
python
def _get_electricity_info_html( apart_id, meter_room): """get html :param apart_id: 栋数 :param meter_room: 宿舍号 """ if apart.get(apart_id) is None: raise KeyError('not support the apart_id= ' + apart_id) post_data = { 'action': 'search', ...
[ "def", "_get_electricity_info_html", "(", "apart_id", ",", "meter_room", ")", ":", "if", "apart", ".", "get", "(", "apart_id", ")", "is", "None", ":", "raise", "KeyError", "(", "'not support the apart_id= '", "+", "apart_id", ")", "post_data", "=", "{", "'acti...
get html :param apart_id: 栋数 :param meter_room: 宿舍号
[ "get", "html" ]
train
https://github.com/Jayin/ETipsService/blob/1a42612a5e5d11bec0ec1a26c99dec6fe216fca4/service/lifeService.py#L50-L64
Jayin/ETipsService
service/lifeService.py
LifeService.get_electricity_info
def get_electricity_info(self, apart_id, meter_room): """get electricity info :param apart_id: 栋数 :param meter_room: 宿舍号 """ apart_id = str(apart_id) meter_room = str(meter_room) try: content = LifeService._get_electricity_info_html(apart_id, ...
python
def get_electricity_info(self, apart_id, meter_room): """get electricity info :param apart_id: 栋数 :param meter_room: 宿舍号 """ apart_id = str(apart_id) meter_room = str(meter_room) try: content = LifeService._get_electricity_info_html(apart_id, ...
[ "def", "get_electricity_info", "(", "self", ",", "apart_id", ",", "meter_room", ")", ":", "apart_id", "=", "str", "(", "apart_id", ")", "meter_room", "=", "str", "(", "meter_room", ")", "try", ":", "content", "=", "LifeService", ".", "_get_electricity_info_htm...
get electricity info :param apart_id: 栋数 :param meter_room: 宿舍号
[ "get", "electricity", "info" ]
train
https://github.com/Jayin/ETipsService/blob/1a42612a5e5d11bec0ec1a26c99dec6fe216fca4/service/lifeService.py#L67-L94
kervi/kervi-core
kervi/hal/gpio.py
IGPIODeviceDriver.set_channels
def set_channels(self, channels): """Sets the state of multiple channels in one operation. :param channels: A dictionary where keys are channels and values the value to set for each channel. :type channels: ``dict`` """ for key in channels: self.set(key...
python
def set_channels(self, channels): """Sets the state of multiple channels in one operation. :param channels: A dictionary where keys are channels and values the value to set for each channel. :type channels: ``dict`` """ for key in channels: self.set(key...
[ "def", "set_channels", "(", "self", ",", "channels", ")", ":", "for", "key", "in", "channels", ":", "self", ".", "set", "(", "key", ",", "channels", "[", "key", "]", ")" ]
Sets the state of multiple channels in one operation. :param channels: A dictionary where keys are channels and values the value to set for each channel. :type channels: ``dict``
[ "Sets", "the", "state", "of", "multiple", "channels", "in", "one", "operation", "." ]
train
https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/hal/gpio.py#L199-L209
slarse/pdfebc-core
pdfebc_core/compress.py
_get_pdf_filenames_at
def _get_pdf_filenames_at(source_directory): """Find all PDF files in the specified directory. Args: source_directory (str): The source directory. Returns: list(str): Filepaths to all PDF files in the specified directory. Raises: ValueError """ if not os.path.isdir(sou...
python
def _get_pdf_filenames_at(source_directory): """Find all PDF files in the specified directory. Args: source_directory (str): The source directory. Returns: list(str): Filepaths to all PDF files in the specified directory. Raises: ValueError """ if not os.path.isdir(sou...
[ "def", "_get_pdf_filenames_at", "(", "source_directory", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "source_directory", ")", ":", "raise", "ValueError", "(", "\"%s is not a directory!\"", "%", "source_directory", ")", "return", "[", "os", ".", ...
Find all PDF files in the specified directory. Args: source_directory (str): The source directory. Returns: list(str): Filepaths to all PDF files in the specified directory. Raises: ValueError
[ "Find", "all", "PDF", "files", "in", "the", "specified", "directory", "." ]
train
https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/compress.py#L36-L52
slarse/pdfebc-core
pdfebc_core/compress.py
compress_pdf
def compress_pdf(filepath, output_path, ghostscript_binary): """Compress a single PDF file. Args: filepath (str): Path to the PDF file. output_path (str): Output path. ghostscript_binary (str): Name/alias of the Ghostscript binary. Raises: ValueError FileNotFoundErr...
python
def compress_pdf(filepath, output_path, ghostscript_binary): """Compress a single PDF file. Args: filepath (str): Path to the PDF file. output_path (str): Output path. ghostscript_binary (str): Name/alias of the Ghostscript binary. Raises: ValueError FileNotFoundErr...
[ "def", "compress_pdf", "(", "filepath", ",", "output_path", ",", "ghostscript_binary", ")", ":", "if", "not", "filepath", ".", "endswith", "(", "PDF_EXTENSION", ")", ":", "raise", "ValueError", "(", "\"Filename must end with .pdf!\\n%s does not.\"", "%", "filepath", ...
Compress a single PDF file. Args: filepath (str): Path to the PDF file. output_path (str): Output path. ghostscript_binary (str): Name/alias of the Ghostscript binary. Raises: ValueError FileNotFoundError
[ "Compress", "a", "single", "PDF", "file", "." ]
train
https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/compress.py#L54-L85
slarse/pdfebc-core
pdfebc_core/compress.py
compress_multiple_pdfs
def compress_multiple_pdfs(source_directory, output_directory, ghostscript_binary): """Compress all PDF files in the current directory and place the output in the given output directory. This is a generator function that first yields the amount of files to be compressed, and then yields the output path of e...
python
def compress_multiple_pdfs(source_directory, output_directory, ghostscript_binary): """Compress all PDF files in the current directory and place the output in the given output directory. This is a generator function that first yields the amount of files to be compressed, and then yields the output path of e...
[ "def", "compress_multiple_pdfs", "(", "source_directory", ",", "output_directory", ",", "ghostscript_binary", ")", ":", "source_paths", "=", "_get_pdf_filenames_at", "(", "source_directory", ")", "yield", "len", "(", "source_paths", ")", "for", "source_path", "in", "s...
Compress all PDF files in the current directory and place the output in the given output directory. This is a generator function that first yields the amount of files to be compressed, and then yields the output path of each file. Args: source_directory (str): Filepath to the source directory. ...
[ "Compress", "all", "PDF", "files", "in", "the", "current", "directory", "and", "place", "the", "output", "in", "the", "given", "output", "directory", ".", "This", "is", "a", "generator", "function", "that", "first", "yields", "the", "amount", "of", "files", ...
train
https://github.com/slarse/pdfebc-core/blob/fc40857bc42365b7434714333e37d7a3487603a0/pdfebc_core/compress.py#L87-L105
oblalex/candv
candv/base.py
Constant._post_init
def _post_init(self, name, container=None): """ Called automatically by container after container's class construction. """ self.name = name self.container = container
python
def _post_init(self, name, container=None): """ Called automatically by container after container's class construction. """ self.name = name self.container = container
[ "def", "_post_init", "(", "self", ",", "name", ",", "container", "=", "None", ")", ":", "self", ".", "name", "=", "name", "self", ".", "container", "=", "container" ]
Called automatically by container after container's class construction.
[ "Called", "automatically", "by", "container", "after", "container", "s", "class", "construction", "." ]
train
https://github.com/oblalex/candv/blob/0b522bd24f4045844a04793b456f1135d093f280/candv/base.py#L35-L40
oblalex/candv
candv/base.py
_ConstantsContainerMeta.to_primitive
def to_primitive(self, context=None): """ .. versionadded:: 1.3.0 """ return { 'name': self.name, 'items': [x.to_primitive(context) for x in self.iterconstants()] }
python
def to_primitive(self, context=None): """ .. versionadded:: 1.3.0 """ return { 'name': self.name, 'items': [x.to_primitive(context) for x in self.iterconstants()] }
[ "def", "to_primitive", "(", "self", ",", "context", "=", "None", ")", ":", "return", "{", "'name'", ":", "self", ".", "name", ",", "'items'", ":", "[", "x", ".", "to_primitive", "(", "context", ")", "for", "x", "in", "self", ".", "iterconstants", "("...
.. versionadded:: 1.3.0
[ "..", "versionadded", "::", "1", ".", "3", ".", "0" ]
train
https://github.com/oblalex/candv/blob/0b522bd24f4045844a04793b456f1135d093f280/candv/base.py#L397-L404
alexhayes/django-toolkit
django_toolkit/storage.py
OverwriteStorage.get_available_name
def get_available_name(self, name): """Returns a filename that's free on the target storage system, and available for new content to be written to. Found at http://djangosnippets.org/snippets/976/ This file storage solves overwrite on upload problem. Another proposed solution w...
python
def get_available_name(self, name): """Returns a filename that's free on the target storage system, and available for new content to be written to. Found at http://djangosnippets.org/snippets/976/ This file storage solves overwrite on upload problem. Another proposed solution w...
[ "def", "get_available_name", "(", "self", ",", "name", ")", ":", "# If the filename already exists, remove it as if it was a true file system", "if", "self", ".", "exists", "(", "name", ")", ":", "os", ".", "remove", "(", "os", ".", "path", ".", "join", "(", "se...
Returns a filename that's free on the target storage system, and available for new content to be written to. Found at http://djangosnippets.org/snippets/976/ This file storage solves overwrite on upload problem. Another proposed solution was to override the save method on the model ...
[ "Returns", "a", "filename", "that", "s", "free", "on", "the", "target", "storage", "system", "and", "available", "for", "new", "content", "to", "be", "written", "to", "." ]
train
https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/storage.py#L7-L28
b3j0f/conf
b3j0f/conf/driver/base.py
ConfDriver.pathresource
def pathresource(self, rscpath=None, logger=None): """Returns specific resource. :param str rscpath: resource path. :param Logger logger: logger to use. :param bool error: raise internal error if True (False by default). :param bool force: create the resource even if rscpath doe...
python
def pathresource(self, rscpath=None, logger=None): """Returns specific resource. :param str rscpath: resource path. :param Logger logger: logger to use. :param bool error: raise internal error if True (False by default). :param bool force: create the resource even if rscpath doe...
[ "def", "pathresource", "(", "self", ",", "rscpath", "=", "None", ",", "logger", "=", "None", ")", ":", "result", "=", "None", "try", ":", "result", "=", "self", ".", "_pathresource", "(", "rscpath", "=", "rscpath", ")", "except", "Exception", "as", "ex...
Returns specific resource. :param str rscpath: resource path. :param Logger logger: logger to use. :param bool error: raise internal error if True (False by default). :param bool force: create the resource even if rscpath does not exist. :return: specific configuration resource.
[ "Returns", "specific", "resource", "." ]
train
https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/driver/base.py#L82-L103
b3j0f/conf
b3j0f/conf/driver/base.py
ConfDriver.getconf
def getconf(self, path, conf=None, logger=None): """Parse a configuration path with input conf and returns parameters by param name. :param str path: conf resource path to parse and from get parameters. :param Configuration conf: conf to fill with path values and conf param ...
python
def getconf(self, path, conf=None, logger=None): """Parse a configuration path with input conf and returns parameters by param name. :param str path: conf resource path to parse and from get parameters. :param Configuration conf: conf to fill with path values and conf param ...
[ "def", "getconf", "(", "self", ",", "path", ",", "conf", "=", "None", ",", "logger", "=", "None", ")", ":", "result", "=", "conf", "pathconf", "=", "None", "rscpaths", "=", "self", ".", "rscpaths", "(", "path", "=", "path", ")", "for", "rscpath", "...
Parse a configuration path with input conf and returns parameters by param name. :param str path: conf resource path to parse and from get parameters. :param Configuration conf: conf to fill with path values and conf param names. :param Logger logger: logger to use in order ...
[ "Parse", "a", "configuration", "path", "with", "input", "conf", "and", "returns", "parameters", "by", "param", "name", "." ]
train
https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/driver/base.py#L105-L135
b3j0f/conf
b3j0f/conf/driver/base.py
ConfDriver.setconf
def setconf(self, conf, rscpath, logger=None): """Set input conf in input path. :param Configuration conf: conf to write to path. :param str rscpath: specific resource path to use. :param Logger logger: used to log info/errors. :param bool error: raise catched errors. :r...
python
def setconf(self, conf, rscpath, logger=None): """Set input conf in input path. :param Configuration conf: conf to write to path. :param str rscpath: specific resource path to use. :param Logger logger: used to log info/errors. :param bool error: raise catched errors. :r...
[ "def", "setconf", "(", "self", ",", "conf", ",", "rscpath", ",", "logger", "=", "None", ")", ":", "resource", "=", "self", ".", "pathresource", "(", "rscpath", "=", "rscpath", ",", "logger", "=", "logger", ")", "if", "resource", "is", "None", ":", "r...
Set input conf in input path. :param Configuration conf: conf to write to path. :param str rscpath: specific resource path to use. :param Logger logger: used to log info/errors. :param bool error: raise catched errors. :raises: ConfDriver.Error in case of error and input error.
[ "Set", "input", "conf", "in", "input", "path", "." ]
train
https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/driver/base.py#L137-L160
b3j0f/conf
b3j0f/conf/driver/base.py
ConfDriver._getconf
def _getconf(self, rscpath, logger=None, conf=None): """Get specific conf from one driver path. :param str rscpath: resource path. :param Logger logger: logger to use. """ result = None resource = self.pathresource(rscpath=rscpath, logger=logger) if resource i...
python
def _getconf(self, rscpath, logger=None, conf=None): """Get specific conf from one driver path. :param str rscpath: resource path. :param Logger logger: logger to use. """ result = None resource = self.pathresource(rscpath=rscpath, logger=logger) if resource i...
[ "def", "_getconf", "(", "self", ",", "rscpath", ",", "logger", "=", "None", ",", "conf", "=", "None", ")", ":", "result", "=", "None", "resource", "=", "self", ".", "pathresource", "(", "rscpath", "=", "rscpath", ",", "logger", "=", "logger", ")", "i...
Get specific conf from one driver path. :param str rscpath: resource path. :param Logger logger: logger to use.
[ "Get", "specific", "conf", "from", "one", "driver", "path", "." ]
train
https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/driver/base.py#L162-L206
minhhoit/yacms
yacms/galleries/models.py
BaseGallery.save
def save(self, delete_zip_import=True, *args, **kwargs): """ If a zip file is uploaded, extract any images from it and add them to the gallery, before removing the zip file. """ super(BaseGallery, self).save(*args, **kwargs) if self.zip_import: zip_file = ZipF...
python
def save(self, delete_zip_import=True, *args, **kwargs): """ If a zip file is uploaded, extract any images from it and add them to the gallery, before removing the zip file. """ super(BaseGallery, self).save(*args, **kwargs) if self.zip_import: zip_file = ZipF...
[ "def", "save", "(", "self", ",", "delete_zip_import", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", "BaseGallery", ",", "self", ")", ".", "save", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "self", ".",...
If a zip file is uploaded, extract any images from it and add them to the gallery, before removing the zip file.
[ "If", "a", "zip", "file", "is", "uploaded", "extract", "any", "images", "from", "it", "and", "add", "them", "to", "the", "gallery", "before", "removing", "the", "zip", "file", "." ]
train
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/galleries/models.py#L51-L111
nickmilon/Hellas
Hellas/Sparta.py
seconds_to_DHMS
def seconds_to_DHMS(seconds, as_str=True): """converts seconds to Days, Hours, Minutes, Seconds :param int seconds: number of seconds :param bool as_string: to return a formated string defaults to True :returns: a formated string if as_str else a dictionary :Example: >>> seconds_to_DHMS(60*...
python
def seconds_to_DHMS(seconds, as_str=True): """converts seconds to Days, Hours, Minutes, Seconds :param int seconds: number of seconds :param bool as_string: to return a formated string defaults to True :returns: a formated string if as_str else a dictionary :Example: >>> seconds_to_DHMS(60*...
[ "def", "seconds_to_DHMS", "(", "seconds", ",", "as_str", "=", "True", ")", ":", "d", "=", "DotDot", "(", ")", "d", ".", "days", "=", "int", "(", "seconds", "//", "(", "3600", "*", "24", ")", ")", "d", ".", "hours", "=", "int", "(", "(", "second...
converts seconds to Days, Hours, Minutes, Seconds :param int seconds: number of seconds :param bool as_string: to return a formated string defaults to True :returns: a formated string if as_str else a dictionary :Example: >>> seconds_to_DHMS(60*60*24) 001-00:00:00 >>> seconds_to...
[ "converts", "seconds", "to", "Days", "Hours", "Minutes", "Seconds" ]
train
https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Sparta.py#L23-L40
nickmilon/Hellas
Hellas/Sparta.py
dict_encode
def dict_encode(in_dict): """returns a new dictionary with encoded values useful for encoding http queries (python < 3)""" if _IS_PY2: out_dict = {} for k, v in list(in_dict.items()): if isinstance(v, unicode): v = v.encode('utf8') elif isinstance(v, str):...
python
def dict_encode(in_dict): """returns a new dictionary with encoded values useful for encoding http queries (python < 3)""" if _IS_PY2: out_dict = {} for k, v in list(in_dict.items()): if isinstance(v, unicode): v = v.encode('utf8') elif isinstance(v, str):...
[ "def", "dict_encode", "(", "in_dict", ")", ":", "if", "_IS_PY2", ":", "out_dict", "=", "{", "}", "for", "k", ",", "v", "in", "list", "(", "in_dict", ".", "items", "(", ")", ")", ":", "if", "isinstance", "(", "v", ",", "unicode", ")", ":", "v", ...
returns a new dictionary with encoded values useful for encoding http queries (python < 3)
[ "returns", "a", "new", "dictionary", "with", "encoded", "values", "useful", "for", "encoding", "http", "queries", "(", "python", "<", "3", ")" ]
train
https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Sparta.py#L100-L113
nickmilon/Hellas
Hellas/Sparta.py
relations_dict
def relations_dict(rel_lst): """constructs a relation's dictionary from a list that describes amphidromus relations between objects :param list rel_lst: a relationships list of the form [[a,b],[c, a, b]] # can include duplicates :returns: a dictionary :Example: >>> rl = [('a', 'b', 'c'), ('a'...
python
def relations_dict(rel_lst): """constructs a relation's dictionary from a list that describes amphidromus relations between objects :param list rel_lst: a relationships list of the form [[a,b],[c, a, b]] # can include duplicates :returns: a dictionary :Example: >>> rl = [('a', 'b', 'c'), ('a'...
[ "def", "relations_dict", "(", "rel_lst", ")", ":", "dc", "=", "{", "}", "for", "c", "in", "rel_lst", ":", "for", "i", "in", "c", ":", "for", "k", "in", "c", ":", "dc", ".", "setdefault", "(", "i", ",", "[", "]", ")", "dc", "[", "i", "]", "....
constructs a relation's dictionary from a list that describes amphidromus relations between objects :param list rel_lst: a relationships list of the form [[a,b],[c, a, b]] # can include duplicates :returns: a dictionary :Example: >>> rl = [('a', 'b', 'c'), ('a', 'x', 'y'), ('x', 'y', 'z')] ...
[ "constructs", "a", "relation", "s", "dictionary", "from", "a", "list", "that", "describes", "amphidromus", "relations", "between", "objects" ]
train
https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Sparta.py#L264-L288
nickmilon/Hellas
Hellas/Sparta.py
chunks
def chunks(sliceable, n): """ returns a list of lists of any slice-able object each of max lentgh n :Parameters: -sliceable: (string|list|tuple) any sliceable object - n max elements of ech chunk :Example: >>> chunksn([1,2,3,4,5,6,7,8,9,'x'], 4) [[1, 2, 3, 4], [5, 6, 7, ...
python
def chunks(sliceable, n): """ returns a list of lists of any slice-able object each of max lentgh n :Parameters: -sliceable: (string|list|tuple) any sliceable object - n max elements of ech chunk :Example: >>> chunksn([1,2,3,4,5,6,7,8,9,'x'], 4) [[1, 2, 3, 4], [5, 6, 7, ...
[ "def", "chunks", "(", "sliceable", ",", "n", ")", ":", "return", "[", "sliceable", "[", "i", ":", "i", "+", "n", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "sliceable", ")", ",", "n", ")", "]" ]
returns a list of lists of any slice-able object each of max lentgh n :Parameters: -sliceable: (string|list|tuple) any sliceable object - n max elements of ech chunk :Example: >>> chunksn([1,2,3,4,5,6,7,8,9,'x'], 4) [[1, 2, 3, 4], [5, 6, 7, 8], [9, 'x']] >>> chunksn('123...
[ "returns", "a", "list", "of", "lists", "of", "any", "slice", "-", "able", "object", "each", "of", "max", "lentgh", "n" ]
train
https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Sparta.py#L291-L305
nickmilon/Hellas
Hellas/Sparta.py
chunks_str
def chunks_str(str, n, separator="\n", fill_blanks_last=True): """returns lines with max n characters :Example: >>> print (chunks_str('123456X', 3)) 123 456 X """ return separator.join(chunks(str, n))
python
def chunks_str(str, n, separator="\n", fill_blanks_last=True): """returns lines with max n characters :Example: >>> print (chunks_str('123456X', 3)) 123 456 X """ return separator.join(chunks(str, n))
[ "def", "chunks_str", "(", "str", ",", "n", ",", "separator", "=", "\"\\n\"", ",", "fill_blanks_last", "=", "True", ")", ":", "return", "separator", ".", "join", "(", "chunks", "(", "str", ",", "n", ")", ")" ]
returns lines with max n characters :Example: >>> print (chunks_str('123456X', 3)) 123 456 X
[ "returns", "lines", "with", "max", "n", "characters" ]
train
https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Sparta.py#L308-L317
nickmilon/Hellas
Hellas/Sparta.py
class_name_str
def class_name_str(obj, skip_parent=False): """ return's object's class name as string """ rt = str(type(obj)).split(" ")[1][1:-2] if skip_parent: rt = rt.split(".")[-1] return rt
python
def class_name_str(obj, skip_parent=False): """ return's object's class name as string """ rt = str(type(obj)).split(" ")[1][1:-2] if skip_parent: rt = rt.split(".")[-1] return rt
[ "def", "class_name_str", "(", "obj", ",", "skip_parent", "=", "False", ")", ":", "rt", "=", "str", "(", "type", "(", "obj", ")", ")", ".", "split", "(", "\" \"", ")", "[", "1", "]", "[", "1", ":", "-", "2", "]", "if", "skip_parent", ":", "rt", ...
return's object's class name as string
[ "return", "s", "object", "s", "class", "name", "as", "string" ]
train
https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Sparta.py#L333-L340
nickmilon/Hellas
Hellas/Sparta.py
AdHocTree.path
def path(self, separator="/"): """:returns: a string representing the path to root element separated by separator""" rt = "" for i in reversed(self): rt = "{}{}{}".format(rt, i.name, separator) return rt[:-1]
python
def path(self, separator="/"): """:returns: a string representing the path to root element separated by separator""" rt = "" for i in reversed(self): rt = "{}{}{}".format(rt, i.name, separator) return rt[:-1]
[ "def", "path", "(", "self", ",", "separator", "=", "\"/\"", ")", ":", "rt", "=", "\"\"", "for", "i", "in", "reversed", "(", "self", ")", ":", "rt", "=", "\"{}{}{}\"", ".", "format", "(", "rt", ",", "i", ".", "name", ",", "separator", ")", "return...
:returns: a string representing the path to root element separated by separator
[ ":", "returns", ":", "a", "string", "representing", "the", "path", "to", "root", "element", "separated", "by", "separator" ]
train
https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Sparta.py#L172-L177
nickmilon/Hellas
Hellas/Sparta.py
AdHocTree.root_and_path
def root_and_path(self): """:returns: a tuple (parent, [members,... ]""" rt = [] curAttr = self while isinstance(curAttr.parent, AdHocTree): rt.append(curAttr.name) curAttr = curAttr.parent rt.reverse() return (curAttr.parent, rt)
python
def root_and_path(self): """:returns: a tuple (parent, [members,... ]""" rt = [] curAttr = self while isinstance(curAttr.parent, AdHocTree): rt.append(curAttr.name) curAttr = curAttr.parent rt.reverse() return (curAttr.parent, rt)
[ "def", "root_and_path", "(", "self", ")", ":", "rt", "=", "[", "]", "curAttr", "=", "self", "while", "isinstance", "(", "curAttr", ".", "parent", ",", "AdHocTree", ")", ":", "rt", ".", "append", "(", "curAttr", ".", "name", ")", "curAttr", "=", "curA...
:returns: a tuple (parent, [members,... ]
[ ":", "returns", ":", "a", "tuple", "(", "parent", "[", "members", "...", "]" ]
train
https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Sparta.py#L179-L187
nickmilon/Hellas
Hellas/Sparta.py
EnumLabels.value_name
def value_name(cls, value): """ Returns the label from a value if label exists otherwise returns the value since method does a reverse look up it is slow """ for k, v in list(cls.__dict__.items()): if v == value: return k return value
python
def value_name(cls, value): """ Returns the label from a value if label exists otherwise returns the value since method does a reverse look up it is slow """ for k, v in list(cls.__dict__.items()): if v == value: return k return value
[ "def", "value_name", "(", "cls", ",", "value", ")", ":", "for", "k", ",", "v", "in", "list", "(", "cls", ".", "__dict__", ".", "items", "(", ")", ")", ":", "if", "v", "==", "value", ":", "return", "k", "return", "value" ]
Returns the label from a value if label exists otherwise returns the value since method does a reverse look up it is slow
[ "Returns", "the", "label", "from", "a", "value", "if", "label", "exists", "otherwise", "returns", "the", "value", "since", "method", "does", "a", "reverse", "look", "up", "it", "is", "slow" ]
train
https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Sparta.py#L253-L261
pbrisk/unicum
unicum/persistentobject.py
PersistentObject._is_visible
def _is_visible(cls, property_name): """ private method to check visible object property to be visible """ if isinstance(property_name, list): return [cls._is_visible(p) for p in property_name] if property_name.startswith('__') and property_name.endswith('__'): return Fal...
python
def _is_visible(cls, property_name): """ private method to check visible object property to be visible """ if isinstance(property_name, list): return [cls._is_visible(p) for p in property_name] if property_name.startswith('__') and property_name.endswith('__'): return Fal...
[ "def", "_is_visible", "(", "cls", ",", "property_name", ")", ":", "if", "isinstance", "(", "property_name", ",", "list", ")", ":", "return", "[", "cls", ".", "_is_visible", "(", "p", ")", "for", "p", "in", "property_name", "]", "if", "property_name", "."...
private method to check visible object property to be visible
[ "private", "method", "to", "check", "visible", "object", "property", "to", "be", "visible" ]
train
https://github.com/pbrisk/unicum/blob/24bfa7355f36847a06646c58e9fd75bd3b689bfe/unicum/persistentobject.py#L58-L64
pbrisk/unicum
unicum/persistentobject.py
PersistentObject._from_class
def _from_class(cls, class_name, module_name=None, *args, **kwargs): """ class method to create object of a given class """ def _get_module(module_name): names = module_name.split(".") module = __import__(names[0]) for i in xrange(1, len(names)): modul...
python
def _from_class(cls, class_name, module_name=None, *args, **kwargs): """ class method to create object of a given class """ def _get_module(module_name): names = module_name.split(".") module = __import__(names[0]) for i in xrange(1, len(names)): modul...
[ "def", "_from_class", "(", "cls", ",", "class_name", ",", "module_name", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "_get_module", "(", "module_name", ")", ":", "names", "=", "module_name", ".", "split", "(", "\".\"", ")",...
class method to create object of a given class
[ "class", "method", "to", "create", "object", "of", "a", "given", "class" ]
train
https://github.com/pbrisk/unicum/blob/24bfa7355f36847a06646c58e9fd75bd3b689bfe/unicum/persistentobject.py#L89-L120
pbrisk/unicum
unicum/persistentobject.py
PersistentObject.from_serializable
def from_serializable(cls, object_dict): """ core class method to create visible objects from a dictionary """ key_class = cls._from_visible(cls.STARTS_WITH + 'class' + cls.ENDS_WITH) key_module = cls._from_visible(cls.STARTS_WITH + 'module' + cls.ENDS_WITH) obj_class = object_dict.pop...
python
def from_serializable(cls, object_dict): """ core class method to create visible objects from a dictionary """ key_class = cls._from_visible(cls.STARTS_WITH + 'class' + cls.ENDS_WITH) key_module = cls._from_visible(cls.STARTS_WITH + 'module' + cls.ENDS_WITH) obj_class = object_dict.pop...
[ "def", "from_serializable", "(", "cls", ",", "object_dict", ")", ":", "key_class", "=", "cls", ".", "_from_visible", "(", "cls", ".", "STARTS_WITH", "+", "'class'", "+", "cls", ".", "ENDS_WITH", ")", "key_module", "=", "cls", ".", "_from_visible", "(", "cl...
core class method to create visible objects from a dictionary
[ "core", "class", "method", "to", "create", "visible", "objects", "from", "a", "dictionary" ]
train
https://github.com/pbrisk/unicum/blob/24bfa7355f36847a06646c58e9fd75bd3b689bfe/unicum/persistentobject.py#L123-L134
pbrisk/unicum
unicum/persistentobject.py
PersistentObject.modify_object
def modify_object(self, property_name, property_value_variant=None): """ api visible method for modifying visible object properties :param property_name: property name :type property_name: string, list or dict :param property_value_variant: property value, must be `None` if prop...
python
def modify_object(self, property_name, property_value_variant=None): """ api visible method for modifying visible object properties :param property_name: property name :type property_name: string, list or dict :param property_value_variant: property value, must be `None` if prop...
[ "def", "modify_object", "(", "self", ",", "property_name", ",", "property_value_variant", "=", "None", ")", ":", "if", "type", "(", "property_name", ")", "is", "dict", ":", "property_value_variant", "=", "property_name", ".", "values", "(", ")", "property_name",...
api visible method for modifying visible object properties :param property_name: property name :type property_name: string, list or dict :param property_value_variant: property value, must be `None` if property_name is of type `dict` :type property_value_variant: various or None ...
[ "api", "visible", "method", "for", "modifying", "visible", "object", "properties" ]
train
https://github.com/pbrisk/unicum/blob/24bfa7355f36847a06646c58e9fd75bd3b689bfe/unicum/persistentobject.py#L164-L192
pbrisk/unicum
unicum/persistentobject.py
PersistentObject._is_modified_property
def _is_modified_property(self, prop): """ True, if the given property is in the modifed members :param prop: :return: """ if type(prop) is str: return prop in self._modified_members return False
python
def _is_modified_property(self, prop): """ True, if the given property is in the modifed members :param prop: :return: """ if type(prop) is str: return prop in self._modified_members return False
[ "def", "_is_modified_property", "(", "self", ",", "prop", ")", ":", "if", "type", "(", "prop", ")", "is", "str", ":", "return", "prop", "in", "self", ".", "_modified_members", "return", "False" ]
True, if the given property is in the modifed members :param prop: :return:
[ "True", "if", "the", "given", "property", "is", "in", "the", "modifed", "members", ":", "param", "prop", ":", ":", "return", ":" ]
train
https://github.com/pbrisk/unicum/blob/24bfa7355f36847a06646c58e9fd75bd3b689bfe/unicum/persistentobject.py#L245-L253
klmitch/bark
bark/handlers.py
wrap_log_handler
def wrap_log_handler(handler): """ Helper function which takes a Python logging handler and wraps it. Returns a callable taking a single argument, which will be wrapped in a log record and passed to the handler's emit() method. :param handler: A logging.Handler instance. :returns: A callable o...
python
def wrap_log_handler(handler): """ Helper function which takes a Python logging handler and wraps it. Returns a callable taking a single argument, which will be wrapped in a log record and passed to the handler's emit() method. :param handler: A logging.Handler instance. :returns: A callable o...
[ "def", "wrap_log_handler", "(", "handler", ")", ":", "# Set the formatter on the handler to be the SimpleFormatter", "handler", ".", "setFormatter", "(", "SimpleFormatter", "(", ")", ")", "# Get file name, line number, and function name for", "# wrap_log_handler()", "obj", "=", ...
Helper function which takes a Python logging handler and wraps it. Returns a callable taking a single argument, which will be wrapped in a log record and passed to the handler's emit() method. :param handler: A logging.Handler instance. :returns: A callable of one argument, which will emit that ...
[ "Helper", "function", "which", "takes", "a", "Python", "logging", "handler", "and", "wraps", "it", ".", "Returns", "a", "callable", "taking", "a", "single", "argument", "which", "will", "be", "wrapped", "in", "a", "log", "record", "and", "passed", "to", "t...
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L38-L69
klmitch/bark
bark/handlers.py
arg_types
def arg_types(**kwargs): """ Mark the expected types of certain arguments. Arguments for which no types are provided default to strings. To specify an argument type, give this decorator a keyword argument, where the argument name is the name of the function argument and the value is a callable...
python
def arg_types(**kwargs): """ Mark the expected types of certain arguments. Arguments for which no types are provided default to strings. To specify an argument type, give this decorator a keyword argument, where the argument name is the name of the function argument and the value is a callable...
[ "def", "arg_types", "(", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "func", ")", ":", "if", "not", "hasattr", "(", "func", ",", "'_bark_types'", ")", ":", "func", ".", "_bark_types", "=", "{", "}", "func", ".", "_bark_types", ".", "update...
Mark the expected types of certain arguments. Arguments for which no types are provided default to strings. To specify an argument type, give this decorator a keyword argument, where the argument name is the name of the function argument and the value is a callable taking one argument, which will conv...
[ "Mark", "the", "expected", "types", "of", "certain", "arguments", ".", "Arguments", "for", "which", "no", "types", "are", "provided", "default", "to", "strings", ".", "To", "specify", "an", "argument", "type", "give", "this", "decorator", "a", "keyword", "ar...
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L72-L90
klmitch/bark
bark/handlers.py
boolean
def boolean(text): """ An alternative to the "bool" argument type which interprets string values. """ tmp = text.lower() if tmp.isdigit(): return bool(int(tmp)) elif tmp in ('t', 'true', 'on', 'yes'): return True elif tmp in ('f', 'false', 'off', 'no'): return Fa...
python
def boolean(text): """ An alternative to the "bool" argument type which interprets string values. """ tmp = text.lower() if tmp.isdigit(): return bool(int(tmp)) elif tmp in ('t', 'true', 'on', 'yes'): return True elif tmp in ('f', 'false', 'off', 'no'): return Fa...
[ "def", "boolean", "(", "text", ")", ":", "tmp", "=", "text", ".", "lower", "(", ")", "if", "tmp", ".", "isdigit", "(", ")", ":", "return", "bool", "(", "int", "(", "tmp", ")", ")", "elif", "tmp", "in", "(", "'t'", ",", "'true'", ",", "'on'", ...
An alternative to the "bool" argument type which interprets string values.
[ "An", "alternative", "to", "the", "bool", "argument", "type", "which", "interprets", "string", "values", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L93-L107
klmitch/bark
bark/handlers.py
address
def address(addr): """ A special argument type that splits a string on ':' and transforms the result into a tuple of host and (integer) port. """ if ':' in addr: # Using rpartition here means we should be able to support # IPv6, but only with a strict syntax host, _sep, port...
python
def address(addr): """ A special argument type that splits a string on ':' and transforms the result into a tuple of host and (integer) port. """ if ':' in addr: # Using rpartition here means we should be able to support # IPv6, but only with a strict syntax host, _sep, port...
[ "def", "address", "(", "addr", ")", ":", "if", "':'", "in", "addr", ":", "# Using rpartition here means we should be able to support", "# IPv6, but only with a strict syntax", "host", ",", "_sep", ",", "port", "=", "addr", ".", "rpartition", "(", "':'", ")", "# Conv...
A special argument type that splits a string on ':' and transforms the result into a tuple of host and (integer) port.
[ "A", "special", "argument", "type", "that", "splits", "a", "string", "on", ":", "and", "transforms", "the", "result", "into", "a", "tuple", "of", "host", "and", "(", "integer", ")", "port", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L119-L138
klmitch/bark
bark/handlers.py
file_handler
def file_handler(name, logname, filename, mode='a', encoding=None, delay=False): """ A Bark logging handler logging output to a named file. Similar to logging.FileHandler. """ return wrap_log_handler(logging.FileHandler( filename, mode=mode, encoding=encoding, delay=delay)...
python
def file_handler(name, logname, filename, mode='a', encoding=None, delay=False): """ A Bark logging handler logging output to a named file. Similar to logging.FileHandler. """ return wrap_log_handler(logging.FileHandler( filename, mode=mode, encoding=encoding, delay=delay)...
[ "def", "file_handler", "(", "name", ",", "logname", ",", "filename", ",", "mode", "=", "'a'", ",", "encoding", "=", "None", ",", "delay", "=", "False", ")", ":", "return", "wrap_log_handler", "(", "logging", ".", "FileHandler", "(", "filename", ",", "mod...
A Bark logging handler logging output to a named file. Similar to logging.FileHandler.
[ "A", "Bark", "logging", "handler", "logging", "output", "to", "a", "named", "file", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L237-L246
klmitch/bark
bark/handlers.py
watched_file_handler
def watched_file_handler(name, logname, filename, mode='a', encoding=None, delay=False): """ A Bark logging handler logging output to a named file. If the file has changed since the last log message was written, it will be closed and reopened. Similar to logging.handlers.W...
python
def watched_file_handler(name, logname, filename, mode='a', encoding=None, delay=False): """ A Bark logging handler logging output to a named file. If the file has changed since the last log message was written, it will be closed and reopened. Similar to logging.handlers.W...
[ "def", "watched_file_handler", "(", "name", ",", "logname", ",", "filename", ",", "mode", "=", "'a'", ",", "encoding", "=", "None", ",", "delay", "=", "False", ")", ":", "return", "wrap_log_handler", "(", "logging", ".", "handlers", ".", "WatchedFileHandler"...
A Bark logging handler logging output to a named file. If the file has changed since the last log message was written, it will be closed and reopened. Similar to logging.handlers.WatchedFileHandler.
[ "A", "Bark", "logging", "handler", "logging", "output", "to", "a", "named", "file", ".", "If", "the", "file", "has", "changed", "since", "the", "last", "log", "message", "was", "written", "it", "will", "be", "closed", "and", "reopened", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L250-L261
klmitch/bark
bark/handlers.py
rotating_file_handler
def rotating_file_handler(name, logname, filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=False): """ A Bark logging handler logging output to a named file. When the file grows close to 'maxBytes', it will be rotated, under control of 'backupCount'. Sim...
python
def rotating_file_handler(name, logname, filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=False): """ A Bark logging handler logging output to a named file. When the file grows close to 'maxBytes', it will be rotated, under control of 'backupCount'. Sim...
[ "def", "rotating_file_handler", "(", "name", ",", "logname", ",", "filename", ",", "mode", "=", "'a'", ",", "maxBytes", "=", "0", ",", "backupCount", "=", "0", ",", "encoding", "=", "None", ",", "delay", "=", "False", ")", ":", "return", "wrap_log_handle...
A Bark logging handler logging output to a named file. When the file grows close to 'maxBytes', it will be rotated, under control of 'backupCount'. Similar to logging.handlers.RotatingFileHandler.
[ "A", "Bark", "logging", "handler", "logging", "output", "to", "a", "named", "file", ".", "When", "the", "file", "grows", "close", "to", "maxBytes", "it", "will", "be", "rotated", "under", "control", "of", "backupCount", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L265-L277
klmitch/bark
bark/handlers.py
timed_rotating_file_handler
def timed_rotating_file_handler(name, logname, filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False): """ A Bark logging handler logging output to a named file. At intervals specified by the 'when', the file wil...
python
def timed_rotating_file_handler(name, logname, filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False): """ A Bark logging handler logging output to a named file. At intervals specified by the 'when', the file wil...
[ "def", "timed_rotating_file_handler", "(", "name", ",", "logname", ",", "filename", ",", "when", "=", "'h'", ",", "interval", "=", "1", ",", "backupCount", "=", "0", ",", "encoding", "=", "None", ",", "delay", "=", "False", ",", "utc", "=", "False", ")...
A Bark logging handler logging output to a named file. At intervals specified by the 'when', the file will be rotated, under control of 'backupCount'. Similar to logging.handlers.TimedRotatingFileHandler.
[ "A", "Bark", "logging", "handler", "logging", "output", "to", "a", "named", "file", ".", "At", "intervals", "specified", "by", "the", "when", "the", "file", "will", "be", "rotated", "under", "control", "of", "backupCount", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L281-L294
klmitch/bark
bark/handlers.py
socket_handler
def socket_handler(name, logname, host, port): """ A Bark logging handler logging output to a stream (TCP) socket. The server listening at the given 'host' and 'port' will be sent a pickled dictionary. Similar to logging.handlers.SocketHandler. """ return wrap_log_handler(logging.handlers....
python
def socket_handler(name, logname, host, port): """ A Bark logging handler logging output to a stream (TCP) socket. The server listening at the given 'host' and 'port' will be sent a pickled dictionary. Similar to logging.handlers.SocketHandler. """ return wrap_log_handler(logging.handlers....
[ "def", "socket_handler", "(", "name", ",", "logname", ",", "host", ",", "port", ")", ":", "return", "wrap_log_handler", "(", "logging", ".", "handlers", ".", "SocketHandler", "(", "host", ",", "port", ")", ")" ]
A Bark logging handler logging output to a stream (TCP) socket. The server listening at the given 'host' and 'port' will be sent a pickled dictionary. Similar to logging.handlers.SocketHandler.
[ "A", "Bark", "logging", "handler", "logging", "output", "to", "a", "stream", "(", "TCP", ")", "socket", ".", "The", "server", "listening", "at", "the", "given", "host", "and", "port", "will", "be", "sent", "a", "pickled", "dictionary", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L298-L307
klmitch/bark
bark/handlers.py
datagram_handler
def datagram_handler(name, logname, host, port): """ A Bark logging handler logging output to a datagram (UDP) socket. The server listening at the given 'host' and 'port' will be sent a pickled dictionary. Similar to logging.handlers.DatagramHandler. """ return wrap_log_handler(logging.han...
python
def datagram_handler(name, logname, host, port): """ A Bark logging handler logging output to a datagram (UDP) socket. The server listening at the given 'host' and 'port' will be sent a pickled dictionary. Similar to logging.handlers.DatagramHandler. """ return wrap_log_handler(logging.han...
[ "def", "datagram_handler", "(", "name", ",", "logname", ",", "host", ",", "port", ")", ":", "return", "wrap_log_handler", "(", "logging", ".", "handlers", ".", "DatagramHandler", "(", "host", ",", "port", ")", ")" ]
A Bark logging handler logging output to a datagram (UDP) socket. The server listening at the given 'host' and 'port' will be sent a pickled dictionary. Similar to logging.handlers.DatagramHandler.
[ "A", "Bark", "logging", "handler", "logging", "output", "to", "a", "datagram", "(", "UDP", ")", "socket", ".", "The", "server", "listening", "at", "the", "given", "host", "and", "port", "will", "be", "sent", "a", "pickled", "dictionary", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L311-L320
klmitch/bark
bark/handlers.py
syslog_handler
def syslog_handler(name, logname, address=('localhost', 514), facility=logging.handlers.SysLogHandler.LOG_USER): """ A Bark logging handler logging output to syslog. By default, sends log messages to localhost on port 514; if this logger doesn't seem to work, confirm that the address...
python
def syslog_handler(name, logname, address=('localhost', 514), facility=logging.handlers.SysLogHandler.LOG_USER): """ A Bark logging handler logging output to syslog. By default, sends log messages to localhost on port 514; if this logger doesn't seem to work, confirm that the address...
[ "def", "syslog_handler", "(", "name", ",", "logname", ",", "address", "=", "(", "'localhost'", ",", "514", ")", ",", "facility", "=", "logging", ".", "handlers", ".", "SysLogHandler", ".", "LOG_USER", ")", ":", "return", "wrap_log_handler", "(", "logging", ...
A Bark logging handler logging output to syslog. By default, sends log messages to localhost on port 514; if this logger doesn't seem to work, confirm that the address is correct. Addresses containing a colon (':') are treated as a hostname and port, while others are interpreted as UNIX domain sockets....
[ "A", "Bark", "logging", "handler", "logging", "output", "to", "syslog", ".", "By", "default", "sends", "log", "messages", "to", "localhost", "on", "port", "514", ";", "if", "this", "logger", "doesn", "t", "seem", "to", "work", "confirm", "that", "the", "...
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L325-L338
klmitch/bark
bark/handlers.py
nt_event_log_handler
def nt_event_log_handler(name, logname, appname, dllname=None, logtype="Application"): """ A Bark logging handler logging output to the NT Event Log. Similar to logging.handlers.NTEventLogHandler. """ return wrap_log_handler(logging.handlers.NTEventLogHandler( appn...
python
def nt_event_log_handler(name, logname, appname, dllname=None, logtype="Application"): """ A Bark logging handler logging output to the NT Event Log. Similar to logging.handlers.NTEventLogHandler. """ return wrap_log_handler(logging.handlers.NTEventLogHandler( appn...
[ "def", "nt_event_log_handler", "(", "name", ",", "logname", ",", "appname", ",", "dllname", "=", "None", ",", "logtype", "=", "\"Application\"", ")", ":", "return", "wrap_log_handler", "(", "logging", ".", "handlers", ".", "NTEventLogHandler", "(", "appname", ...
A Bark logging handler logging output to the NT Event Log. Similar to logging.handlers.NTEventLogHandler.
[ "A", "Bark", "logging", "handler", "logging", "output", "to", "the", "NT", "Event", "Log", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L342-L351
klmitch/bark
bark/handlers.py
smtp_handler
def smtp_handler(name, logname, mailhost, fromaddr, toaddrs, subject, credentials=None): """ A Bark logging handler logging output via SMTP. To specify a non-standard SMTP port, use the "host:port" format. To specify multiple "To" addresses, separate them with commas. To specify ...
python
def smtp_handler(name, logname, mailhost, fromaddr, toaddrs, subject, credentials=None): """ A Bark logging handler logging output via SMTP. To specify a non-standard SMTP port, use the "host:port" format. To specify multiple "To" addresses, separate them with commas. To specify ...
[ "def", "smtp_handler", "(", "name", ",", "logname", ",", "mailhost", ",", "fromaddr", ",", "toaddrs", ",", "subject", ",", "credentials", "=", "None", ")", ":", "return", "wrap_log_handler", "(", "logging", ".", "handlers", ".", "SMTPHandler", "(", "mailhost...
A Bark logging handler logging output via SMTP. To specify a non-standard SMTP port, use the "host:port" format. To specify multiple "To" addresses, separate them with commas. To specify authentication credentials, supply a "username:password". Similar to logging.handlers.SMTPHandler.
[ "A", "Bark", "logging", "handler", "logging", "output", "via", "SMTP", ".", "To", "specify", "a", "non", "-", "standard", "SMTP", "port", "use", "the", "host", ":", "port", "format", ".", "To", "specify", "multiple", "To", "addresses", "separate", "them", ...
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L355-L367
klmitch/bark
bark/handlers.py
http_handler
def http_handler(name, logname, host, url, method="GET"): """ A Bark logging handler logging output to an HTTP server, using either GET or POST semantics. Similar to logging.handlers.HTTPHandler. """ return wrap_log_handler(logging.handlers.HTTPHandler( host, url, method=method))
python
def http_handler(name, logname, host, url, method="GET"): """ A Bark logging handler logging output to an HTTP server, using either GET or POST semantics. Similar to logging.handlers.HTTPHandler. """ return wrap_log_handler(logging.handlers.HTTPHandler( host, url, method=method))
[ "def", "http_handler", "(", "name", ",", "logname", ",", "host", ",", "url", ",", "method", "=", "\"GET\"", ")", ":", "return", "wrap_log_handler", "(", "logging", ".", "handlers", ".", "HTTPHandler", "(", "host", ",", "url", ",", "method", "=", "method"...
A Bark logging handler logging output to an HTTP server, using either GET or POST semantics. Similar to logging.handlers.HTTPHandler.
[ "A", "Bark", "logging", "handler", "logging", "output", "to", "an", "HTTP", "server", "using", "either", "GET", "or", "POST", "semantics", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L371-L380
klmitch/bark
bark/handlers.py
_lookup_handler
def _lookup_handler(name): """ Look up the implementation of a named handler. Broken out for testing purposes. :param name: The name of the handler to look up. :returns: A factory function for the log handler. """ # Look up and load the handler factory for ep in pkg_resources.iter_en...
python
def _lookup_handler(name): """ Look up the implementation of a named handler. Broken out for testing purposes. :param name: The name of the handler to look up. :returns: A factory function for the log handler. """ # Look up and load the handler factory for ep in pkg_resources.iter_en...
[ "def", "_lookup_handler", "(", "name", ")", ":", "# Look up and load the handler factory", "for", "ep", "in", "pkg_resources", ".", "iter_entry_points", "(", "'bark.handler'", ",", "name", ")", ":", "try", ":", "# Load and return the handler factory", "return", "ep", ...
Look up the implementation of a named handler. Broken out for testing purposes. :param name: The name of the handler to look up. :returns: A factory function for the log handler.
[ "Look", "up", "the", "implementation", "of", "a", "named", "handler", ".", "Broken", "out", "for", "testing", "purposes", "." ]
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L383-L402
klmitch/bark
bark/handlers.py
get_handler
def get_handler(name, logname, args): """ Retrieve a logger given its name and initialize it by passing it appropriate arguments from the configuration. (Unnecessary arguments will be logged, and missing required arguments will cause a TypeError to be thrown.) The result should be a callable. ...
python
def get_handler(name, logname, args): """ Retrieve a logger given its name and initialize it by passing it appropriate arguments from the configuration. (Unnecessary arguments will be logged, and missing required arguments will cause a TypeError to be thrown.) The result should be a callable. ...
[ "def", "get_handler", "(", "name", ",", "logname", ",", "args", ")", ":", "factory", "=", "_lookup_handler", "(", "name", ")", "# What arguments are we passing to the handler?", "available", "=", "set", "(", "args", ".", "keys", "(", ")", ")", "# Now, let's intr...
Retrieve a logger given its name and initialize it by passing it appropriate arguments from the configuration. (Unnecessary arguments will be logged, and missing required arguments will cause a TypeError to be thrown.) The result should be a callable. :param name: The name of the handler to look up. ...
[ "Retrieve", "a", "logger", "given", "its", "name", "and", "initialize", "it", "by", "passing", "it", "appropriate", "arguments", "from", "the", "configuration", ".", "(", "Unnecessary", "arguments", "will", "be", "logged", "and", "missing", "required", "argument...
train
https://github.com/klmitch/bark/blob/6e0e002d55f01fee27e3e45bb86e30af1bfeef36/bark/handlers.py#L405-L481
nicholasbishop/trask
trask/phase2.py
make_keys_safe
def make_keys_safe(dct): """Modify the keys in |dct| to be valid attribute names.""" result = {} for key, val in dct.items(): key = key.replace('-', '_') if key in keyword.kwlist: key = key + '_' result[key] = val return result
python
def make_keys_safe(dct): """Modify the keys in |dct| to be valid attribute names.""" result = {} for key, val in dct.items(): key = key.replace('-', '_') if key in keyword.kwlist: key = key + '_' result[key] = val return result
[ "def", "make_keys_safe", "(", "dct", ")", ":", "result", "=", "{", "}", "for", "key", ",", "val", "in", "dct", ".", "items", "(", ")", ":", "key", "=", "key", ".", "replace", "(", "'-'", ",", "'_'", ")", "if", "key", "in", "keyword", ".", "kwli...
Modify the keys in |dct| to be valid attribute names.
[ "Modify", "the", "keys", "in", "|dct|", "to", "be", "valid", "attribute", "names", "." ]
train
https://github.com/nicholasbishop/trask/blob/a97688425f70b539c7710b498627da9a6e39afd8/trask/phase2.py#L36-L44
robertdfrench/psychic-disco
psychic_disco/cli.py
_apply_args_to_func
def _apply_args_to_func(global_args, func): """ Unpacks the argparse Namespace object and applies its contents as normal arguments to the function func """ global_args = vars(global_args) local_args = dict() for argument in inspect.getargspec(func).args: local_args[argument] = global_args[ar...
python
def _apply_args_to_func(global_args, func): """ Unpacks the argparse Namespace object and applies its contents as normal arguments to the function func """ global_args = vars(global_args) local_args = dict() for argument in inspect.getargspec(func).args: local_args[argument] = global_args[ar...
[ "def", "_apply_args_to_func", "(", "global_args", ",", "func", ")", ":", "global_args", "=", "vars", "(", "global_args", ")", "local_args", "=", "dict", "(", ")", "for", "argument", "in", "inspect", ".", "getargspec", "(", "func", ")", ".", "args", ":", ...
Unpacks the argparse Namespace object and applies its contents as normal arguments to the function func
[ "Unpacks", "the", "argparse", "Namespace", "object", "and", "applies", "its", "contents", "as", "normal", "arguments", "to", "the", "function", "func" ]
train
https://github.com/robertdfrench/psychic-disco/blob/3cf167b44c64d64606691fc186be7d9ef8e8e938/psychic_disco/cli.py#L10-L17
robertdfrench/psychic-disco
psychic_disco/cli.py
subcommand
def subcommand(f): """ Define a subcommand for the psychic_disco function Expects functions to supply a list of their arguments Converts these to arg_parse arguments, and transforms the argparse Namespace object so that commands can be invoked as though they are normal functions (which they are)""" ...
python
def subcommand(f): """ Define a subcommand for the psychic_disco function Expects functions to supply a list of their arguments Converts these to arg_parse arguments, and transforms the argparse Namespace object so that commands can be invoked as though they are normal functions (which they are)""" ...
[ "def", "subcommand", "(", "f", ")", ":", "sp", "=", "subparsers", ".", "add_parser", "(", "f", ".", "__name__", ",", "help", "=", "f", ".", "__doc__", ")", "for", "argument", "in", "inspect", ".", "getargspec", "(", "f", ")", ".", "args", ":", "sp"...
Define a subcommand for the psychic_disco function Expects functions to supply a list of their arguments Converts these to arg_parse arguments, and transforms the argparse Namespace object so that commands can be invoked as though they are normal functions (which they are)
[ "Define", "a", "subcommand", "for", "the", "psychic_disco", "function", "Expects", "functions", "to", "supply", "a", "list", "of", "their", "arguments", "Converts", "these", "to", "arg_parse", "arguments", "and", "transforms", "the", "argparse", "Namespace", "obje...
train
https://github.com/robertdfrench/psychic-disco/blob/3cf167b44c64d64606691fc186be7d9ef8e8e938/psychic_disco/cli.py#L20-L30
hoh/Hereby
hereby.py
Here.open
def open(self, path, mode='r', *args, **kwargs): """Proxy to function `open` with path to the current file.""" return open(os.path.join(os.path.dirname(self.path), path), mode=mode, *args, **kwargs)
python
def open(self, path, mode='r', *args, **kwargs): """Proxy to function `open` with path to the current file.""" return open(os.path.join(os.path.dirname(self.path), path), mode=mode, *args, **kwargs)
[ "def", "open", "(", "self", ",", "path", ",", "mode", "=", "'r'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "open", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "self", ".", "path", ")...
Proxy to function `open` with path to the current file.
[ "Proxy", "to", "function", "open", "with", "path", "to", "the", "current", "file", "." ]
train
https://github.com/hoh/Hereby/blob/a5f8bcdcb667e1fe1e64f542162e15ec31741505/hereby.py#L33-L36
hoh/Hereby
hereby.py
Here.abspath
def abspath(self, path): """Return absolute path for a path relative to the current file.""" return os.path.abspath(os.path.join(os.path.dirname(self.path), path))
python
def abspath(self, path): """Return absolute path for a path relative to the current file.""" return os.path.abspath(os.path.join(os.path.dirname(self.path), path))
[ "def", "abspath", "(", "self", ",", "path", ")", ":", "return", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "self", ".", "path", ")", ",", "path", ")", ")" ]
Return absolute path for a path relative to the current file.
[ "Return", "absolute", "path", "for", "a", "path", "relative", "to", "the", "current", "file", "." ]
train
https://github.com/hoh/Hereby/blob/a5f8bcdcb667e1fe1e64f542162e15ec31741505/hereby.py#L38-L40
exekias/droplet
droplet/commands.py
run
def run(cmd, background=False): """ Executes the given command If background flag is True the command will run in background and this method will return a :class:`Popen` object If background is False (default) the command will run in this thread and this method will return stdout. A Comma...
python
def run(cmd, background=False): """ Executes the given command If background flag is True the command will run in background and this method will return a :class:`Popen` object If background is False (default) the command will run in this thread and this method will return stdout. A Comma...
[ "def", "run", "(", "cmd", ",", "background", "=", "False", ")", ":", "logger", ".", "debug", "(", "'Running command: %s'", "%", "cmd", ")", "if", "background", ":", "return", "subprocess", ".", "Popen", "(", "cmd", ",", "shell", "=", "True", ",", "clos...
Executes the given command If background flag is True the command will run in background and this method will return a :class:`Popen` object If background is False (default) the command will run in this thread and this method will return stdout. A CommandException will be raised if command fails
[ "Executes", "the", "given", "command" ]
train
https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/commands.py#L37-L65
caspervg/pylex
src/pylex/lot.py
LotRoute.lot
def lot(self, id, user=True, dependencies=True, comments=True, votes=True, no_strip=False): """ Retrieve the lot with given identifier :param id: Identifier of the lot to retrieve :param user: Should user (authenticated) information be returned (e.g. last_downloaded) :param depe...
python
def lot(self, id, user=True, dependencies=True, comments=True, votes=True, no_strip=False): """ Retrieve the lot with given identifier :param id: Identifier of the lot to retrieve :param user: Should user (authenticated) information be returned (e.g. last_downloaded) :param depe...
[ "def", "lot", "(", "self", ",", "id", ",", "user", "=", "True", ",", "dependencies", "=", "True", ",", "comments", "=", "True", ",", "votes", "=", "True", ",", "no_strip", "=", "False", ")", ":", "args", "=", "{", "}", "if", "user", ":", "args", ...
Retrieve the lot with given identifier :param id: Identifier of the lot to retrieve :param user: Should user (authenticated) information be returned (e.g. last_downloaded) :param dependencies: Should a dependency list be returned :param comments: Should a list of comments be returned ...
[ "Retrieve", "the", "lot", "with", "given", "identifier" ]
train
https://github.com/caspervg/pylex/blob/bae00c705b5331b0f784d42b27e19dc3541e1b5a/src/pylex/lot.py#L13-L38
caspervg/pylex
src/pylex/lot.py
LotRoute.download
def download(self, id, directory): """ Download the file with given identifier to the given directory :param id: Identifier of the lot to download :param directory: Directory where the downloaded ZIP should be stored :return: None """ url = (self._base + 'lot/{0}/...
python
def download(self, id, directory): """ Download the file with given identifier to the given directory :param id: Identifier of the lot to download :param directory: Directory where the downloaded ZIP should be stored :return: None """ url = (self._base + 'lot/{0}/...
[ "def", "download", "(", "self", ",", "id", ",", "directory", ")", ":", "url", "=", "(", "self", ".", "_base", "+", "'lot/{0}/download'", ")", ".", "format", "(", "id", ")", "r", "=", "requests", ".", "get", "(", "url", ",", "auth", "=", "self", "...
Download the file with given identifier to the given directory :param id: Identifier of the lot to download :param directory: Directory where the downloaded ZIP should be stored :return: None
[ "Download", "the", "file", "with", "given", "identifier", "to", "the", "given", "directory", ":", "param", "id", ":", "Identifier", "of", "the", "lot", "to", "download", ":", "param", "directory", ":", "Directory", "where", "the", "downloaded", "ZIP", "shoul...
train
https://github.com/caspervg/pylex/blob/bae00c705b5331b0f784d42b27e19dc3541e1b5a/src/pylex/lot.py#L49-L67
caspervg/pylex
src/pylex/lot.py
LotRoute.rate
def rate(self, id, comment=None, vote=None): """ Add a rating (vote and/or comment) to the lot with given identifier :param id: Identifier to add the rating to :param comment: String with the comment to add. It should have len > 0 when entered. :param vote: int with the vote to a...
python
def rate(self, id, comment=None, vote=None): """ Add a rating (vote and/or comment) to the lot with given identifier :param id: Identifier to add the rating to :param comment: String with the comment to add. It should have len > 0 when entered. :param vote: int with the vote to a...
[ "def", "rate", "(", "self", ",", "id", ",", "comment", "=", "None", ",", "vote", "=", "None", ")", ":", "rating", "=", "{", "}", "if", "vote", "is", "not", "None", ":", "if", "1", "<=", "vote", "<=", "3", ":", "rating", "[", "'rating'", "]", ...
Add a rating (vote and/or comment) to the lot with given identifier :param id: Identifier to add the rating to :param comment: String with the comment to add. It should have len > 0 when entered. :param vote: int with the vote to add. It should be greater than 0 and smaller than 4 when entered. ...
[ "Add", "a", "rating", "(", "vote", "and", "/", "or", "comment", ")", "to", "the", "lot", "with", "given", "identifier", ":", "param", "id", ":", "Identifier", "to", "add", "the", "rating", "to", ":", "param", "comment", ":", "String", "with", "the", ...
train
https://github.com/caspervg/pylex/blob/bae00c705b5331b0f784d42b27e19dc3541e1b5a/src/pylex/lot.py#L77-L99
caspervg/pylex
src/pylex/lot.py
LotRoute.set_dependencies
def set_dependencies(self, id, internal=list(), external=list()): """ Sets the dependency string (for the LEX Dependency Tracker) for a lot. Requires administrator access. :param id: Identifier of the lot :param internal: List of dependency identifiers for internal files (LEX lot...
python
def set_dependencies(self, id, internal=list(), external=list()): """ Sets the dependency string (for the LEX Dependency Tracker) for a lot. Requires administrator access. :param id: Identifier of the lot :param internal: List of dependency identifiers for internal files (LEX lot...
[ "def", "set_dependencies", "(", "self", ",", "id", ",", "internal", "=", "list", "(", ")", ",", "external", "=", "list", "(", ")", ")", ":", "dependency_str", "=", "'NONE'", "if", "len", "(", "internal", ")", ">", "0", "or", "len", "(", "external", ...
Sets the dependency string (for the LEX Dependency Tracker) for a lot. Requires administrator access. :param id: Identifier of the lot :param internal: List of dependency identifiers for internal files (LEX lots) that the lot depends on :param external: List of (name, link) tuples for ex...
[ "Sets", "the", "dependency", "string", "(", "for", "the", "LEX", "Dependency", "Tracker", ")", "for", "a", "lot", ".", "Requires", "administrator", "access", ".", ":", "param", "id", ":", "Identifier", "of", "the", "lot", ":", "param", "internal", ":", "...
train
https://github.com/caspervg/pylex/blob/bae00c705b5331b0f784d42b27e19dc3541e1b5a/src/pylex/lot.py#L101-L129
fred49/linshare-api
linshareapi/user/threadentries.py
ThreadEntries.upload
def upload(self, thread_uuid, file_path, description=None): """ Upload a file to LinShare using its rest api. The uploaded document uuid will be returned""" url = "threads/%s/entries" % thread_uuid return self.core.upload(file_path, url, description)
python
def upload(self, thread_uuid, file_path, description=None): """ Upload a file to LinShare using its rest api. The uploaded document uuid will be returned""" url = "threads/%s/entries" % thread_uuid return self.core.upload(file_path, url, description)
[ "def", "upload", "(", "self", ",", "thread_uuid", ",", "file_path", ",", "description", "=", "None", ")", ":", "url", "=", "\"threads/%s/entries\"", "%", "thread_uuid", "return", "self", ".", "core", ".", "upload", "(", "file_path", ",", "url", ",", "descr...
Upload a file to LinShare using its rest api. The uploaded document uuid will be returned
[ "Upload", "a", "file", "to", "LinShare", "using", "its", "rest", "api", ".", "The", "uploaded", "document", "uuid", "will", "be", "returned" ]
train
https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/user/threadentries.py#L84-L88
fred49/linshare-api
linshareapi/user/threadentries.py
WorkgroupContent.get
def get(self, wg_uuid, uuid, tree=False): """ Get one workgroup member.""" url = "%(base)s/%(wg_uuid)s/nodes/%(uuid)s" % { 'base': self.local_base_url, 'wg_uuid': wg_uuid, 'uuid': uuid } param = {} if tree: param['tree'] = True ...
python
def get(self, wg_uuid, uuid, tree=False): """ Get one workgroup member.""" url = "%(base)s/%(wg_uuid)s/nodes/%(uuid)s" % { 'base': self.local_base_url, 'wg_uuid': wg_uuid, 'uuid': uuid } param = {} if tree: param['tree'] = True ...
[ "def", "get", "(", "self", ",", "wg_uuid", ",", "uuid", ",", "tree", "=", "False", ")", ":", "url", "=", "\"%(base)s/%(wg_uuid)s/nodes/%(uuid)s\"", "%", "{", "'base'", ":", "self", ".", "local_base_url", ",", "'wg_uuid'", ":", "wg_uuid", ",", "'uuid'", ":"...
Get one workgroup member.
[ "Get", "one", "workgroup", "member", "." ]
train
https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/user/threadentries.py#L141-L155
fred49/linshare-api
linshareapi/user/threadentries.py
WorkgroupContent.head
def head(self, wg_uuid, uuid): """ Get one workgroup node.""" url = "%(base)s/%(wg_uuid)s/nodes/%(uuid)s" % { 'base': self.local_base_url, 'wg_uuid': wg_uuid, 'uuid': uuid } # return self.core.head(url) try: # workaround ...
python
def head(self, wg_uuid, uuid): """ Get one workgroup node.""" url = "%(base)s/%(wg_uuid)s/nodes/%(uuid)s" % { 'base': self.local_base_url, 'wg_uuid': wg_uuid, 'uuid': uuid } # return self.core.head(url) try: # workaround ...
[ "def", "head", "(", "self", ",", "wg_uuid", ",", "uuid", ")", ":", "url", "=", "\"%(base)s/%(wg_uuid)s/nodes/%(uuid)s\"", "%", "{", "'base'", ":", "self", ".", "local_base_url", ",", "'wg_uuid'", ":", "wg_uuid", ",", "'uuid'", ":", "uuid", "}", "# return sel...
Get one workgroup node.
[ "Get", "one", "workgroup", "node", "." ]
train
https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/user/threadentries.py#L159-L171
fred49/linshare-api
linshareapi/user/threadentries.py
WorkgroupContent.list
def list(self, wg_uuid, parent=None, flat=False, node_types=None): """ Get a list of workgroup nodes.""" url = "%(base)s/%(wg_uuid)s/nodes" % { 'base': self.local_base_url, 'wg_uuid': wg_uuid } param = [] if parent: # I use only the last folder...
python
def list(self, wg_uuid, parent=None, flat=False, node_types=None): """ Get a list of workgroup nodes.""" url = "%(base)s/%(wg_uuid)s/nodes" % { 'base': self.local_base_url, 'wg_uuid': wg_uuid } param = [] if parent: # I use only the last folder...
[ "def", "list", "(", "self", ",", "wg_uuid", ",", "parent", "=", "None", ",", "flat", "=", "False", ",", "node_types", "=", "None", ")", ":", "url", "=", "\"%(base)s/%(wg_uuid)s/nodes\"", "%", "{", "'base'", ":", "self", ".", "local_base_url", ",", "'wg_u...
Get a list of workgroup nodes.
[ "Get", "a", "list", "of", "workgroup", "nodes", "." ]
train
https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/user/threadentries.py#L175-L197
fred49/linshare-api
linshareapi/user/threadentries.py
WorkgroupContent.upload
def upload(self, wg_uuid, file_path, description=None, parent=None): """ Upload a file to LinShare using its rest api. The uploaded document uuid will be returned""" url = "%(base)s/%(wg_uuid)s/nodes" % { 'base': self.local_base_url, 'wg_uuid': wg_uuid } p...
python
def upload(self, wg_uuid, file_path, description=None, parent=None): """ Upload a file to LinShare using its rest api. The uploaded document uuid will be returned""" url = "%(base)s/%(wg_uuid)s/nodes" % { 'base': self.local_base_url, 'wg_uuid': wg_uuid } p...
[ "def", "upload", "(", "self", ",", "wg_uuid", ",", "file_path", ",", "description", "=", "None", ",", "parent", "=", "None", ")", ":", "url", "=", "\"%(base)s/%(wg_uuid)s/nodes\"", "%", "{", "'base'", ":", "self", ".", "local_base_url", ",", "'wg_uuid'", "...
Upload a file to LinShare using its rest api. The uploaded document uuid will be returned
[ "Upload", "a", "file", "to", "LinShare", "using", "its", "rest", "api", ".", "The", "uploaded", "document", "uuid", "will", "be", "returned" ]
train
https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/user/threadentries.py#L201-L219
fred49/linshare-api
linshareapi/user/threadentries.py
WorkgroupFolders.update
def update(self, data): """ Update meta of one document.""" self.debug(data) self._check(data) wg_uuid = data.get('workGroup') self.log.debug("wg_uuid : %s ", wg_uuid) uuid = data.get('uuid') url = "%(base)s/%(wg_uuid)s/nodes/%(uuid)s" % { 'base': self...
python
def update(self, data): """ Update meta of one document.""" self.debug(data) self._check(data) wg_uuid = data.get('workGroup') self.log.debug("wg_uuid : %s ", wg_uuid) uuid = data.get('uuid') url = "%(base)s/%(wg_uuid)s/nodes/%(uuid)s" % { 'base': self...
[ "def", "update", "(", "self", ",", "data", ")", ":", "self", ".", "debug", "(", "data", ")", "self", ".", "_check", "(", "data", ")", "wg_uuid", "=", "data", ".", "get", "(", "'workGroup'", ")", "self", ".", "log", ".", "debug", "(", "\"wg_uuid : %...
Update meta of one document.
[ "Update", "meta", "of", "one", "document", "." ]
train
https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/user/threadentries.py#L321-L333
mattimck/python-exist
exist/exist.py
Exist.arquire_attributes
def arquire_attributes(self, attributes, active=True): """ Claims a list of attributes for the current client. Can also disable attributes. Returns update response object. """ attribute_update = self._post_object(self.update_api.attributes.acquire, attributes) return Exis...
python
def arquire_attributes(self, attributes, active=True): """ Claims a list of attributes for the current client. Can also disable attributes. Returns update response object. """ attribute_update = self._post_object(self.update_api.attributes.acquire, attributes) return Exis...
[ "def", "arquire_attributes", "(", "self", ",", "attributes", ",", "active", "=", "True", ")", ":", "attribute_update", "=", "self", ".", "_post_object", "(", "self", ".", "update_api", ".", "attributes", ".", "acquire", ",", "attributes", ")", "return", "Exi...
Claims a list of attributes for the current client. Can also disable attributes. Returns update response object.
[ "Claims", "a", "list", "of", "attributes", "for", "the", "current", "client", ".", "Can", "also", "disable", "attributes", ".", "Returns", "update", "response", "object", "." ]
train
https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/exist.py#L72-L78
mattimck/python-exist
exist/exist.py
Exist.release_attributes
def release_attributes(self, attributes, active=True): """ Releases named attributes from this service. Returns update response object. """ attribute_update = self._post_object(self.update_api.attributes.release, attributes) return ExistAttributeResponse(attribute_update)
python
def release_attributes(self, attributes, active=True): """ Releases named attributes from this service. Returns update response object. """ attribute_update = self._post_object(self.update_api.attributes.release, attributes) return ExistAttributeResponse(attribute_update)
[ "def", "release_attributes", "(", "self", ",", "attributes", ",", "active", "=", "True", ")", ":", "attribute_update", "=", "self", ".", "_post_object", "(", "self", ".", "update_api", ".", "attributes", ".", "release", ",", "attributes", ")", "return", "Exi...
Releases named attributes from this service. Returns update response object.
[ "Releases", "named", "attributes", "from", "this", "service", ".", "Returns", "update", "response", "object", "." ]
train
https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/exist.py#L80-L85
mattimck/python-exist
exist/exist.py
Exist.owned_attributes
def owned_attributes(self): """ Returns a list of attributes owned by this service. """ attributes = self._get_object(self.update_api.attributes.owned) return [ExistOwnedAttributeResponse(attribute) for attribute in attributes]
python
def owned_attributes(self): """ Returns a list of attributes owned by this service. """ attributes = self._get_object(self.update_api.attributes.owned) return [ExistOwnedAttributeResponse(attribute) for attribute in attributes]
[ "def", "owned_attributes", "(", "self", ")", ":", "attributes", "=", "self", ".", "_get_object", "(", "self", ".", "update_api", ".", "attributes", ".", "owned", ")", "return", "[", "ExistOwnedAttributeResponse", "(", "attribute", ")", "for", "attribute", "in"...
Returns a list of attributes owned by this service.
[ "Returns", "a", "list", "of", "attributes", "owned", "by", "this", "service", "." ]
train
https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/exist.py#L87-L92
mattimck/python-exist
exist/exist.py
Exist.update_attributes
def update_attributes(self, attributes): """ Releases named attributes from this service. Returns update response object. """ attribute_update = self._post_object(self.update_api.attributes.update, attributes) return ExistAttributeResponse(attribute_update)
python
def update_attributes(self, attributes): """ Releases named attributes from this service. Returns update response object. """ attribute_update = self._post_object(self.update_api.attributes.update, attributes) return ExistAttributeResponse(attribute_update)
[ "def", "update_attributes", "(", "self", ",", "attributes", ")", ":", "attribute_update", "=", "self", ".", "_post_object", "(", "self", ".", "update_api", ".", "attributes", ".", "update", ",", "attributes", ")", "return", "ExistAttributeResponse", "(", "attrib...
Releases named attributes from this service. Returns update response object.
[ "Releases", "named", "attributes", "from", "this", "service", ".", "Returns", "update", "response", "object", "." ]
train
https://github.com/mattimck/python-exist/blob/2c4be9d176d8e8007c4e020ee7cd6263a2096abb/exist/exist.py#L94-L99
hkff/FodtlMon
fodtlmon/fotl/fotl.py
IPredicate.eval
def eval(self, valuation=None, trace=None): """ This method should be always called by subclasses :param valuation :param trace :return: Arguments evaluation """ args2 = [] for a in self.args: if isinstance(a, Function) or isinstance(a, IPredic...
python
def eval(self, valuation=None, trace=None): """ This method should be always called by subclasses :param valuation :param trace :return: Arguments evaluation """ args2 = [] for a in self.args: if isinstance(a, Function) or isinstance(a, IPredic...
[ "def", "eval", "(", "self", ",", "valuation", "=", "None", ",", "trace", "=", "None", ")", ":", "args2", "=", "[", "]", "for", "a", "in", "self", ".", "args", ":", "if", "isinstance", "(", "a", ",", "Function", ")", "or", "isinstance", "(", "a", ...
This method should be always called by subclasses :param valuation :param trace :return: Arguments evaluation
[ "This", "method", "should", "be", "always", "called", "by", "subclasses", ":", "param", "valuation", ":", "param", "trace", ":", "return", ":", "Arguments", "evaluation" ]
train
https://github.com/hkff/FodtlMon/blob/0c9015a1a1f0a4a64d52945c86b45441d5871c56/fodtlmon/fotl/fotl.py#L154-L178
hkff/FodtlMon
fodtlmon/fotl/fotl.py
Function.eval
def eval(self, valuation=None, trace=None): """ This method should be override to return some value :param valuation :param trace :return: """ return super().eval(valuation=valuation, trace=trace)
python
def eval(self, valuation=None, trace=None): """ This method should be override to return some value :param valuation :param trace :return: """ return super().eval(valuation=valuation, trace=trace)
[ "def", "eval", "(", "self", ",", "valuation", "=", "None", ",", "trace", "=", "None", ")", ":", "return", "super", "(", ")", ".", "eval", "(", "valuation", "=", "valuation", ",", "trace", "=", "trace", ")" ]
This method should be override to return some value :param valuation :param trace :return:
[ "This", "method", "should", "be", "override", "to", "return", "some", "value", ":", "param", "valuation", ":", "param", "trace", ":", "return", ":" ]
train
https://github.com/hkff/FodtlMon/blob/0c9015a1a1f0a4a64d52945c86b45441d5871c56/fodtlmon/fotl/fotl.py#L201-L208
frejanordsiek/GeminiMotorDrive
GeminiMotorDrive/compilers/move_sequence.py
compile_sequence
def compile_sequence(cycles, program_or_profile='program', unit_converter=None): """ Makes the command list for a move sequence. Constructs the list of commands to execute the given sequence of motion. Program/command line commands or profile commands can be generated depending on ...
python
def compile_sequence(cycles, program_or_profile='program', unit_converter=None): """ Makes the command list for a move sequence. Constructs the list of commands to execute the given sequence of motion. Program/command line commands or profile commands can be generated depending on ...
[ "def", "compile_sequence", "(", "cycles", ",", "program_or_profile", "=", "'program'", ",", "unit_converter", "=", "None", ")", ":", "# If needed, cycles needs to be converted to motor units.", "if", "unit_converter", "is", "None", ":", "cv_cycles", "=", "cycles", "else...
Makes the command list for a move sequence. Constructs the list of commands to execute the given sequence of motion. Program/command line commands or profile commands can be generated depending on the value of `program_or_profile` so that the commands can be used to construct a program or profile later...
[ "Makes", "the", "command", "list", "for", "a", "move", "sequence", "." ]
train
https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/compilers/move_sequence.py#L28-L265
frejanordsiek/GeminiMotorDrive
GeminiMotorDrive/compilers/move_sequence.py
get_sequence_time
def get_sequence_time(cycles, unit_converter=None, eres=None): """ Calculates the time the move sequence will take to complete. Calculates the amount of time it will take to complete the given move sequence. Types of motion supported are moves from one position to another (the motion will always come t...
python
def get_sequence_time(cycles, unit_converter=None, eres=None): """ Calculates the time the move sequence will take to complete. Calculates the amount of time it will take to complete the given move sequence. Types of motion supported are moves from one position to another (the motion will always come t...
[ "def", "get_sequence_time", "(", "cycles", ",", "unit_converter", "=", "None", ",", "eres", "=", "None", ")", ":", "# If we are doing unit conversion, then that is equivalent to motor", "# units but with eres equal to one.", "if", "unit_converter", "is", "not", "None", ":",...
Calculates the time the move sequence will take to complete. Calculates the amount of time it will take to complete the given move sequence. Types of motion supported are moves from one position to another (the motion will always come to a stop before doing the next motion), waiting a given interval of...
[ "Calculates", "the", "time", "the", "move", "sequence", "will", "take", "to", "complete", "." ]
train
https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/compilers/move_sequence.py#L268-L318
frejanordsiek/GeminiMotorDrive
GeminiMotorDrive/compilers/move_sequence.py
move_time
def move_time(move, eres): """ Calculates the time it takes to do a move. Calculates how long it will take to complete a move of the motor. It is assumed that the motor will decerate to a stop for the end of the move as opposed to keep moving at velocity. Everything is in motor units which are enc...
python
def move_time(move, eres): """ Calculates the time it takes to do a move. Calculates how long it will take to complete a move of the motor. It is assumed that the motor will decerate to a stop for the end of the move as opposed to keep moving at velocity. Everything is in motor units which are enc...
[ "def", "move_time", "(", "move", ",", "eres", ")", ":", "# Grab the move parameters. If the deceleration is given as zero,", "# that means it has the same value as the acceleration. Distance is", "# converted to the same units as the others by dividing by the", "# encoder resolution. The absol...
Calculates the time it takes to do a move. Calculates how long it will take to complete a move of the motor. It is assumed that the motor will decerate to a stop for the end of the move as opposed to keep moving at velocity. Everything is in motor units which are encoder counts for distance, pitch...
[ "Calculates", "the", "time", "it", "takes", "to", "do", "a", "move", "." ]
train
https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/compilers/move_sequence.py#L321-L397
frejanordsiek/GeminiMotorDrive
GeminiMotorDrive/compilers/move_sequence.py
convert_sequence_to_motor_units
def convert_sequence_to_motor_units(cycles, unit_converter): """ Converts a move sequence to motor units. Converts a move sequence to motor units using the provied converter. Parameters ---------- cycles : iterable of dicts The iterable of cycles of motion to do one after another. See ...
python
def convert_sequence_to_motor_units(cycles, unit_converter): """ Converts a move sequence to motor units. Converts a move sequence to motor units using the provied converter. Parameters ---------- cycles : iterable of dicts The iterable of cycles of motion to do one after another. See ...
[ "def", "convert_sequence_to_motor_units", "(", "cycles", ",", "unit_converter", ")", ":", "# Make a deep copy of cycles so that the conversions don't damage", "# the original one.", "cv_cycles", "=", "copy", ".", "deepcopy", "(", "cycles", ")", "# Go through each cycle and do the...
Converts a move sequence to motor units. Converts a move sequence to motor units using the provied converter. Parameters ---------- cycles : iterable of dicts The iterable of cycles of motion to do one after another. See ``compile_sequence`` for format. unit_converter : UnitConvert...
[ "Converts", "a", "move", "sequence", "to", "motor", "units", "." ]
train
https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/compilers/move_sequence.py#L399-L442
razor-x/dichalcogenides
dichalcogenides/superconductor/induced.py
Induced.Δk(
def Δk(self): """The superconducting parameter :math:`Δ_\\mathbf{k}` as a function of the energy :math:`E`. :return: :math:`Δ(E)` :rtype: func """ Δc, Δv = self.Δc, self.Δv cos = self._energy.trig('cos θ') return lambda e: (1 / 2) * ((Δc + Δv) + (Δc - Δv)...
python
def Δk(self): """The superconducting parameter :math:`Δ_\\mathbf{k}` as a function of the energy :math:`E`. :return: :math:`Δ(E)` :rtype: func """ Δc, Δv = self.Δc, self.Δv cos = self._energy.trig('cos θ') return lambda e: (1 / 2) * ((Δc + Δv) + (Δc - Δv)...
[ "def", "Δk(", "s", "elf)", ":", "", "Δc,", " ", "v =", "s", "lf.Δ", "c", ", s", "e", "f.Δv", "", "", "cos", "=", "self", ".", "_energy", ".", "trig", "(", "'cos θ')", "", "return", "lambda", "e", ":", "(", "1", "/", "2", ")", "*", "(", "(",...
The superconducting parameter :math:`Δ_\\mathbf{k}` as a function of the energy :math:`E`. :return: :math:`Δ(E)` :rtype: func
[ "The", "superconducting", "parameter", ":", "math", ":", "Δ_", "\\\\", "mathbf", "{", "k", "}", "as", "a", "function", "of", "the", "energy", ":", "math", ":", "E", "." ]
train
https://github.com/razor-x/dichalcogenides/blob/0fa1995a3a328b679c9926f73239d0ecdc6e5d3d/dichalcogenides/superconductor/induced.py#L34-L43
Sean1708/HipPy
hippy/compiler.py
Compiler.compile
def compile(self): """Return Hip string if already compiled else compile it.""" if self.buffer is None: self.buffer = self._compile_value(self.data, 0) return self.buffer.strip()
python
def compile(self): """Return Hip string if already compiled else compile it.""" if self.buffer is None: self.buffer = self._compile_value(self.data, 0) return self.buffer.strip()
[ "def", "compile", "(", "self", ")", ":", "if", "self", ".", "buffer", "is", "None", ":", "self", ".", "buffer", "=", "self", ".", "_compile_value", "(", "self", ".", "data", ",", "0", ")", "return", "self", ".", "buffer", ".", "strip", "(", ")" ]
Return Hip string if already compiled else compile it.
[ "Return", "Hip", "string", "if", "already", "compiled", "else", "compile", "it", "." ]
train
https://github.com/Sean1708/HipPy/blob/d0ea8fb1e417f1fedaa8e215e3d420b90c4de691/hippy/compiler.py#L15-L20
Sean1708/HipPy
hippy/compiler.py
Compiler._compile_value
def _compile_value(self, data, indent_level): """Dispatch to correct compilation method.""" if isinstance(data, dict): return self._compile_key_val(data, indent_level) elif isinstance(data, list): return self._compile_list(data, indent_level) else: ret...
python
def _compile_value(self, data, indent_level): """Dispatch to correct compilation method.""" if isinstance(data, dict): return self._compile_key_val(data, indent_level) elif isinstance(data, list): return self._compile_list(data, indent_level) else: ret...
[ "def", "_compile_value", "(", "self", ",", "data", ",", "indent_level", ")", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "return", "self", ".", "_compile_key_val", "(", "data", ",", "indent_level", ")", "elif", "isinstance", "(", "data", ...
Dispatch to correct compilation method.
[ "Dispatch", "to", "correct", "compilation", "method", "." ]
train
https://github.com/Sean1708/HipPy/blob/d0ea8fb1e417f1fedaa8e215e3d420b90c4de691/hippy/compiler.py#L22-L29
Sean1708/HipPy
hippy/compiler.py
Compiler._compile_literal
def _compile_literal(self, data): """Write correct representation of literal.""" if data is None: return 'nil' elif data is True: return 'yes' elif data is False: return 'no' else: return repr(data)
python
def _compile_literal(self, data): """Write correct representation of literal.""" if data is None: return 'nil' elif data is True: return 'yes' elif data is False: return 'no' else: return repr(data)
[ "def", "_compile_literal", "(", "self", ",", "data", ")", ":", "if", "data", "is", "None", ":", "return", "'nil'", "elif", "data", "is", "True", ":", "return", "'yes'", "elif", "data", "is", "False", ":", "return", "'no'", "else", ":", "return", "repr"...
Write correct representation of literal.
[ "Write", "correct", "representation", "of", "literal", "." ]
train
https://github.com/Sean1708/HipPy/blob/d0ea8fb1e417f1fedaa8e215e3d420b90c4de691/hippy/compiler.py#L31-L40
Sean1708/HipPy
hippy/compiler.py
Compiler._compile_list
def _compile_list(self, data, indent_level): """Correctly write possibly nested list.""" if len(data) == 0: return '--' elif not any(isinstance(i, (dict, list)) for i in data): return ', '.join(self._compile_literal(value) for value in data) else: # 'e...
python
def _compile_list(self, data, indent_level): """Correctly write possibly nested list.""" if len(data) == 0: return '--' elif not any(isinstance(i, (dict, list)) for i in data): return ', '.join(self._compile_literal(value) for value in data) else: # 'e...
[ "def", "_compile_list", "(", "self", ",", "data", ",", "indent_level", ")", ":", "if", "len", "(", "data", ")", "==", "0", ":", "return", "'--'", "elif", "not", "any", "(", "isinstance", "(", "i", ",", "(", "dict", ",", "list", ")", ")", "for", "...
Correctly write possibly nested list.
[ "Correctly", "write", "possibly", "nested", "list", "." ]
train
https://github.com/Sean1708/HipPy/blob/d0ea8fb1e417f1fedaa8e215e3d420b90c4de691/hippy/compiler.py#L42-L80
Sean1708/HipPy
hippy/compiler.py
Compiler._compile_key_val
def _compile_key_val(self, data, indent_level): """Compile a dictionary.""" buffer = '' for (key, val) in data.items(): buffer += self._indent * indent_level # TODO: assumes key is a string buffer += key + ':' if isinstance(val, dict): ...
python
def _compile_key_val(self, data, indent_level): """Compile a dictionary.""" buffer = '' for (key, val) in data.items(): buffer += self._indent * indent_level # TODO: assumes key is a string buffer += key + ':' if isinstance(val, dict): ...
[ "def", "_compile_key_val", "(", "self", ",", "data", ",", "indent_level", ")", ":", "buffer", "=", "''", "for", "(", "key", ",", "val", ")", "in", "data", ".", "items", "(", ")", ":", "buffer", "+=", "self", ".", "_indent", "*", "indent_level", "# TO...
Compile a dictionary.
[ "Compile", "a", "dictionary", "." ]
train
https://github.com/Sean1708/HipPy/blob/d0ea8fb1e417f1fedaa8e215e3d420b90c4de691/hippy/compiler.py#L82-L103
boronine/discipline
disciplinesite/tools.py
word
def word(cap=False): """ This function generates a fake word by creating between two and three random syllables and then joining them together. """ syllables = [] for x in range(random.randint(2,3)): syllables.append(_syllable()) word = "".join(syllables) if cap: word = word[0].u...
python
def word(cap=False): """ This function generates a fake word by creating between two and three random syllables and then joining them together. """ syllables = [] for x in range(random.randint(2,3)): syllables.append(_syllable()) word = "".join(syllables) if cap: word = word[0].u...
[ "def", "word", "(", "cap", "=", "False", ")", ":", "syllables", "=", "[", "]", "for", "x", "in", "range", "(", "random", ".", "randint", "(", "2", ",", "3", ")", ")", ":", "syllables", ".", "append", "(", "_syllable", "(", ")", ")", "word", "="...
This function generates a fake word by creating between two and three random syllables and then joining them together.
[ "This", "function", "generates", "a", "fake", "word", "by", "creating", "between", "two", "and", "three", "random", "syllables", "and", "then", "joining", "them", "together", "." ]
train
https://github.com/boronine/discipline/blob/68bea9bc2198cc91cee49a6e2d0f3333cc9bf476/disciplinesite/tools.py#L23-L32
treycucco/bidon
bidon/db/access/data_access.py
transaction
def transaction(data_access): """Wrap statements in a transaction. If the statements succeed, commit, otherwise rollback. :param data_access: a DataAccess instance """ old_autocommit = data_access.autocommit data_access.autocommit = False try: yield data_access except RollbackTransaction as ex: d...
python
def transaction(data_access): """Wrap statements in a transaction. If the statements succeed, commit, otherwise rollback. :param data_access: a DataAccess instance """ old_autocommit = data_access.autocommit data_access.autocommit = False try: yield data_access except RollbackTransaction as ex: d...
[ "def", "transaction", "(", "data_access", ")", ":", "old_autocommit", "=", "data_access", ".", "autocommit", "data_access", ".", "autocommit", "=", "False", "try", ":", "yield", "data_access", "except", "RollbackTransaction", "as", "ex", ":", "data_access", ".", ...
Wrap statements in a transaction. If the statements succeed, commit, otherwise rollback. :param data_access: a DataAccess instance
[ "Wrap", "statements", "in", "a", "transaction", ".", "If", "the", "statements", "succeed", "commit", "otherwise", "rollback", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L425-L442
treycucco/bidon
bidon/db/access/data_access.py
autocommit
def autocommit(data_access): """Make statements autocommit. :param data_access: a DataAccess instance """ if not data_access.autocommit: data_access.commit() old_autocommit = data_access.autocommit data_access.autocommit = True try: yield data_access finally: data_access.autocommit = old_au...
python
def autocommit(data_access): """Make statements autocommit. :param data_access: a DataAccess instance """ if not data_access.autocommit: data_access.commit() old_autocommit = data_access.autocommit data_access.autocommit = True try: yield data_access finally: data_access.autocommit = old_au...
[ "def", "autocommit", "(", "data_access", ")", ":", "if", "not", "data_access", ".", "autocommit", ":", "data_access", ".", "commit", "(", ")", "old_autocommit", "=", "data_access", ".", "autocommit", "data_access", ".", "autocommit", "=", "True", "try", ":", ...
Make statements autocommit. :param data_access: a DataAccess instance
[ "Make", "statements", "autocommit", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L446-L458
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.autocommit
def autocommit(self, value): """Set the autocommit value. :param value: the new autocommit value """ logger.debug("Setting autocommit from %s to %s", self.autocommit, value) self.core.set_autocommit(self.connection, value)
python
def autocommit(self, value): """Set the autocommit value. :param value: the new autocommit value """ logger.debug("Setting autocommit from %s to %s", self.autocommit, value) self.core.set_autocommit(self.connection, value)
[ "def", "autocommit", "(", "self", ",", "value", ")", ":", "logger", ".", "debug", "(", "\"Setting autocommit from %s to %s\"", ",", "self", ".", "autocommit", ",", "value", ")", "self", ".", "core", ".", "set_autocommit", "(", "self", ".", "connection", ",",...
Set the autocommit value. :param value: the new autocommit value
[ "Set", "the", "autocommit", "value", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L79-L85
treycucco/bidon
bidon/db/access/data_access.py
DataAccess._configure_connection
def _configure_connection(self, name, value): """Sets a Postgres run-time connection configuration parameter. :param name: the name of the parameter :param value: a list of values matching the placeholders """ self.update("pg_settings", dict(setting=value), dict(name=name))
python
def _configure_connection(self, name, value): """Sets a Postgres run-time connection configuration parameter. :param name: the name of the parameter :param value: a list of values matching the placeholders """ self.update("pg_settings", dict(setting=value), dict(name=name))
[ "def", "_configure_connection", "(", "self", ",", "name", ",", "value", ")", ":", "self", ".", "update", "(", "\"pg_settings\"", ",", "dict", "(", "setting", "=", "value", ")", ",", "dict", "(", "name", "=", "name", ")", ")" ]
Sets a Postgres run-time connection configuration parameter. :param name: the name of the parameter :param value: a list of values matching the placeholders
[ "Sets", "a", "Postgres", "run", "-", "time", "connection", "configuration", "parameter", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L87-L93
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.open
def open(self, *, autocommit=False): """Sets the connection with the core's open method. :param autocommit: the default autocommit state :type autocommit: boolean :return: self """ if self.connection is not None: raise Exception("Connection already set") self.connection = self.core.op...
python
def open(self, *, autocommit=False): """Sets the connection with the core's open method. :param autocommit: the default autocommit state :type autocommit: boolean :return: self """ if self.connection is not None: raise Exception("Connection already set") self.connection = self.core.op...
[ "def", "open", "(", "self", ",", "*", ",", "autocommit", "=", "False", ")", ":", "if", "self", ".", "connection", "is", "not", "None", ":", "raise", "Exception", "(", "\"Connection already set\"", ")", "self", ".", "connection", "=", "self", ".", "core",...
Sets the connection with the core's open method. :param autocommit: the default autocommit state :type autocommit: boolean :return: self
[ "Sets", "the", "connection", "with", "the", "core", "s", "open", "method", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L95-L110
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.close
def close(self, *, commit=True): """Closes the connection via the core's close method. :param commit: if true the current transaction is commited, otherwise it is rolled back :type commit: boolean :return: self """ self.core.close(self.connection, commit=commit) self.connection = None r...
python
def close(self, *, commit=True): """Closes the connection via the core's close method. :param commit: if true the current transaction is commited, otherwise it is rolled back :type commit: boolean :return: self """ self.core.close(self.connection, commit=commit) self.connection = None r...
[ "def", "close", "(", "self", ",", "*", ",", "commit", "=", "True", ")", ":", "self", ".", "core", ".", "close", "(", "self", ".", "connection", ",", "commit", "=", "commit", ")", "self", ".", "connection", "=", "None", "return", "self" ]
Closes the connection via the core's close method. :param commit: if true the current transaction is commited, otherwise it is rolled back :type commit: boolean :return: self
[ "Closes", "the", "connection", "via", "the", "core", "s", "close", "method", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L112-L121
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.execute
def execute(self, query_string, params=None): """Executes a query. Returns the resulting cursor. :query_string: the parameterized query string :params: can be either a tuple or a dictionary, and must match the parameterization style of the query :return: a cursor object """ cr = se...
python
def execute(self, query_string, params=None): """Executes a query. Returns the resulting cursor. :query_string: the parameterized query string :params: can be either a tuple or a dictionary, and must match the parameterization style of the query :return: a cursor object """ cr = se...
[ "def", "execute", "(", "self", ",", "query_string", ",", "params", "=", "None", ")", ":", "cr", "=", "self", ".", "connection", ".", "cursor", "(", ")", "logger", ".", "info", "(", "\"SQL: %s (%s)\"", ",", "query_string", ",", "params", ")", "self", "....
Executes a query. Returns the resulting cursor. :query_string: the parameterized query string :params: can be either a tuple or a dictionary, and must match the parameterization style of the query :return: a cursor object
[ "Executes", "a", "query", ".", "Returns", "the", "resulting", "cursor", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L123-L139
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.callproc
def callproc(self, name, params, param_types=None): """Calls a procedure. :param name: the name of the procedure :param params: a list or tuple of parameters to pass to the procedure. :param param_types: a list or tuple of type names. If given, each param will be cast via sql_wr...
python
def callproc(self, name, params, param_types=None): """Calls a procedure. :param name: the name of the procedure :param params: a list or tuple of parameters to pass to the procedure. :param param_types: a list or tuple of type names. If given, each param will be cast via sql_wr...
[ "def", "callproc", "(", "self", ",", "name", ",", "params", ",", "param_types", "=", "None", ")", ":", "if", "param_types", ":", "placeholders", "=", "[", "self", ".", "sql_writer", ".", "typecast", "(", "self", ".", "sql_writer", ".", "to_placeholder", ...
Calls a procedure. :param name: the name of the procedure :param params: a list or tuple of parameters to pass to the procedure. :param param_types: a list or tuple of type names. If given, each param will be cast via sql_writers typecast method. This is useful to disambiguate proce...
[ "Calls", "a", "procedure", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L141-L161
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.get_callproc_signature
def get_callproc_signature(self, name, param_types): """Returns a procedure's signature from the name and list of types. :name: the name of the procedure :params: can be either strings, or 2-tuples. 2-tuples must be of the form (name, db_type). :return: the procedure's signature """ if isinstan...
python
def get_callproc_signature(self, name, param_types): """Returns a procedure's signature from the name and list of types. :name: the name of the procedure :params: can be either strings, or 2-tuples. 2-tuples must be of the form (name, db_type). :return: the procedure's signature """ if isinstan...
[ "def", "get_callproc_signature", "(", "self", ",", "name", ",", "param_types", ")", ":", "if", "isinstance", "(", "param_types", "[", "0", "]", ",", "(", "list", ",", "tuple", ")", ")", ":", "params", "=", "[", "self", ".", "sql_writer", ".", "to_place...
Returns a procedure's signature from the name and list of types. :name: the name of the procedure :params: can be either strings, or 2-tuples. 2-tuples must be of the form (name, db_type). :return: the procedure's signature
[ "Returns", "a", "procedure", "s", "signature", "from", "the", "name", "and", "list", "of", "types", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L163-L175
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.find
def find(self, table_name, constraints=None, *, columns=None, order_by=None): """Returns the first record that matches the given criteria. :table_name: the name of the table to search on :constraints: is any construct that can be parsed by SqlWriter.parse_constraints. :columns: either a string or a lis...
python
def find(self, table_name, constraints=None, *, columns=None, order_by=None): """Returns the first record that matches the given criteria. :table_name: the name of the table to search on :constraints: is any construct that can be parsed by SqlWriter.parse_constraints. :columns: either a string or a lis...
[ "def", "find", "(", "self", ",", "table_name", ",", "constraints", "=", "None", ",", "*", ",", "columns", "=", "None", ",", "order_by", "=", "None", ")", ":", "query_string", ",", "params", "=", "self", ".", "sql_writer", ".", "get_find_all_query", "(", ...
Returns the first record that matches the given criteria. :table_name: the name of the table to search on :constraints: is any construct that can be parsed by SqlWriter.parse_constraints. :columns: either a string or a list of column names :order_by: the order by clause
[ "Returns", "the", "first", "record", "that", "matches", "the", "given", "criteria", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L177-L188
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.find_all
def find_all(self, table_name, constraints=None, *, columns=None, order_by=None, limiting=None): """Returns all records that match a given criteria. :table_name: the name of the table to search on :constraints: is any construct that can be parsed by SqlWriter.parse_constraints. :columns: either a strin...
python
def find_all(self, table_name, constraints=None, *, columns=None, order_by=None, limiting=None): """Returns all records that match a given criteria. :table_name: the name of the table to search on :constraints: is any construct that can be parsed by SqlWriter.parse_constraints. :columns: either a strin...
[ "def", "find_all", "(", "self", ",", "table_name", ",", "constraints", "=", "None", ",", "*", ",", "columns", "=", "None", ",", "order_by", "=", "None", ",", "limiting", "=", "None", ")", ":", "query_string", ",", "params", "=", "self", ".", "sql_write...
Returns all records that match a given criteria. :table_name: the name of the table to search on :constraints: is any construct that can be parsed by SqlWriter.parse_constraints. :columns: either a string or a list of column names :order_by: the order by clause
[ "Returns", "all", "records", "that", "match", "a", "given", "criteria", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L190-L201
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.page
def page(self, table_name, paging, constraints=None, *, columns=None, order_by=None, get_count=True): """Performs a find_all method with paging. :param table_name: the name of the table to search on :param paging: is a tuple containing (page, page_size). :param constraints: is any construct ...
python
def page(self, table_name, paging, constraints=None, *, columns=None, order_by=None, get_count=True): """Performs a find_all method with paging. :param table_name: the name of the table to search on :param paging: is a tuple containing (page, page_size). :param constraints: is any construct ...
[ "def", "page", "(", "self", ",", "table_name", ",", "paging", ",", "constraints", "=", "None", ",", "*", ",", "columns", "=", "None", ",", "order_by", "=", "None", ",", "get_count", "=", "True", ")", ":", "if", "get_count", ":", "count", "=", "self",...
Performs a find_all method with paging. :param table_name: the name of the table to search on :param paging: is a tuple containing (page, page_size). :param constraints: is any construct that can be parsed by SqlWriter.parse_constraints. :param columns: either a string or a list of column names :pa...
[ "Performs", "a", "find_all", "method", "with", "paging", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L203-L229
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.update
def update(self, table_name, values, constraints=None, *, returning=None): """Builds and executes and update statement. :param table_name: the name of the table to update :param values: can be either a dict or an enuerable of 2-tuples in the form (column, value). :param constraints: can be any construc...
python
def update(self, table_name, values, constraints=None, *, returning=None): """Builds and executes and update statement. :param table_name: the name of the table to update :param values: can be either a dict or an enuerable of 2-tuples in the form (column, value). :param constraints: can be any construc...
[ "def", "update", "(", "self", ",", "table_name", ",", "values", ",", "constraints", "=", "None", ",", "*", ",", "returning", "=", "None", ")", ":", "if", "constraints", "is", "None", ":", "constraints", "=", "\"1=1\"", "assignments", ",", "assignment_param...
Builds and executes and update statement. :param table_name: the name of the table to update :param values: can be either a dict or an enuerable of 2-tuples in the form (column, value). :param constraints: can be any construct that can be parsed by SqlWriter.parse_constraints. Howev...
[ "Builds", "and", "executes", "and", "update", "statement", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L231-L267
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.insert
def insert(self, table_name, values, *, returning=None, upsert=None): """Builds and executes an insert statement. :param table_name: the name of the table to insert into :param values: can be either a dict or an enumerable of 2-tuples in the form (column, value). :param returning: the columns to return...
python
def insert(self, table_name, values, *, returning=None, upsert=None): """Builds and executes an insert statement. :param table_name: the name of the table to insert into :param values: can be either a dict or an enumerable of 2-tuples in the form (column, value). :param returning: the columns to return...
[ "def", "insert", "(", "self", ",", "table_name", ",", "values", ",", "*", ",", "returning", "=", "None", ",", "upsert", "=", "None", ")", ":", "if", "isinstance", "(", "values", ",", "dict", ")", ":", "names", "=", "values", ".", "keys", "(", ")", ...
Builds and executes an insert statement. :param table_name: the name of the table to insert into :param values: can be either a dict or an enumerable of 2-tuples in the form (column, value). :param returning: the columns to return after updating. Only works for cores that support the ...
[ "Builds", "and", "executes", "an", "insert", "statement", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L269-L340
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.delete
def delete(self, table_name, constraints=None): """Builds and executes an delete statement. :param table_name: the name of the table to delete from :param constraints: can be any construct that can be parsed by SqlWriter.parse_constraints. :return: a cursor object """ if constraints is None: ...
python
def delete(self, table_name, constraints=None): """Builds and executes an delete statement. :param table_name: the name of the table to delete from :param constraints: can be any construct that can be parsed by SqlWriter.parse_constraints. :return: a cursor object """ if constraints is None: ...
[ "def", "delete", "(", "self", ",", "table_name", ",", "constraints", "=", "None", ")", ":", "if", "constraints", "is", "None", ":", "constraints", "=", "\"1=1\"", "where", ",", "params", "=", "self", ".", "sql_writer", ".", "parse_constraints", "(", "const...
Builds and executes an delete statement. :param table_name: the name of the table to delete from :param constraints: can be any construct that can be parsed by SqlWriter.parse_constraints. :return: a cursor object
[ "Builds", "and", "executes", "an", "delete", "statement", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L342-L353
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.count
def count(self, table_name, constraints=None, *, extract="index"): """Returns the count of records in a table. If the default cursor is a tuple or named tuple, this method will work without specifying an extract parameter. If it is a dict cursor, it is necessary to specify any value other than 'index' ...
python
def count(self, table_name, constraints=None, *, extract="index"): """Returns the count of records in a table. If the default cursor is a tuple or named tuple, this method will work without specifying an extract parameter. If it is a dict cursor, it is necessary to specify any value other than 'index' ...
[ "def", "count", "(", "self", ",", "table_name", ",", "constraints", "=", "None", ",", "*", ",", "extract", "=", "\"index\"", ")", ":", "where", ",", "params", "=", "self", ".", "sql_writer", ".", "parse_constraints", "(", "constraints", ")", "sql", "=", ...
Returns the count of records in a table. If the default cursor is a tuple or named tuple, this method will work without specifying an extract parameter. If it is a dict cursor, it is necessary to specify any value other than 'index' for extract. This method will not work with cursors that aren't like tuple...
[ "Returns", "the", "count", "of", "records", "in", "a", "table", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L355-L371
treycucco/bidon
bidon/db/access/data_access.py
DataAccess.get_scalar
def get_scalar(self, cursor, index=0): """Returns a single value from the first returned record from a cursor. By default it will get cursor.fecthone()[0] which works with tuples and namedtuples. For dict cursor it is necessary to specify index. This method will not work with cursors that aren't indexa...
python
def get_scalar(self, cursor, index=0): """Returns a single value from the first returned record from a cursor. By default it will get cursor.fecthone()[0] which works with tuples and namedtuples. For dict cursor it is necessary to specify index. This method will not work with cursors that aren't indexa...
[ "def", "get_scalar", "(", "self", ",", "cursor", ",", "index", "=", "0", ")", ":", "if", "isinstance", "(", "index", ",", "int", ")", ":", "return", "cursor", ".", "fetchone", "(", ")", "[", "index", "]", "else", ":", "return", "get_value", "(", "c...
Returns a single value from the first returned record from a cursor. By default it will get cursor.fecthone()[0] which works with tuples and namedtuples. For dict cursor it is necessary to specify index. This method will not work with cursors that aren't indexable. :param cursor: a cursor object :...
[ "Returns", "a", "single", "value", "from", "the", "first", "returned", "record", "from", "a", "cursor", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/db/access/data_access.py#L373-L386