partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
Grid._interpolationFunctionFactory
Returns a function F(x,y,z) that interpolates any values on the grid. _interpolationFunctionFactory(self,spline_order=3,cval=None) --> F *cval* is set to :meth:`Grid.grid.min`. *cval* cannot be chosen too large or too small or NaN because otherwise the spline interpolation breaks down ...
gridData/core.py
def _interpolationFunctionFactory(self, spline_order=None, cval=None): """Returns a function F(x,y,z) that interpolates any values on the grid. _interpolationFunctionFactory(self,spline_order=3,cval=None) --> F *cval* is set to :meth:`Grid.grid.min`. *cval* cannot be chosen too large o...
def _interpolationFunctionFactory(self, spline_order=None, cval=None): """Returns a function F(x,y,z) that interpolates any values on the grid. _interpolationFunctionFactory(self,spline_order=3,cval=None) --> F *cval* is set to :meth:`Grid.grid.min`. *cval* cannot be chosen too large o...
[ "Returns", "a", "function", "F", "(", "x", "y", "z", ")", "that", "interpolates", "any", "values", "on", "the", "grid", "." ]
MDAnalysis/GridDataFormats
python
https://github.com/MDAnalysis/GridDataFormats/blob/3eeb0432f8cf856912436e4f3e7aba99d3c916be/gridData/core.py#L549-L607
[ "def", "_interpolationFunctionFactory", "(", "self", ",", "spline_order", "=", "None", ",", "cval", "=", "None", ")", ":", "# for scipy >=0.9: should use scipy.interpolate.griddata", "# http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html#scipy.interpolat...
3eeb0432f8cf856912436e4f3e7aba99d3c916be
valid
CCP4.read
Populate the instance from the ccp4 file *filename*.
gridData/CCP4.py
def read(self, filename): """Populate the instance from the ccp4 file *filename*.""" if filename is not None: self.filename = filename with open(self.filename, 'rb') as ccp4: h = self.header = self._read_header(ccp4) nentries = h['nc'] * h['nr'] * h['ns'] ...
def read(self, filename): """Populate the instance from the ccp4 file *filename*.""" if filename is not None: self.filename = filename with open(self.filename, 'rb') as ccp4: h = self.header = self._read_header(ccp4) nentries = h['nc'] * h['nr'] * h['ns'] ...
[ "Populate", "the", "instance", "from", "the", "ccp4", "file", "*", "filename", "*", "." ]
MDAnalysis/GridDataFormats
python
https://github.com/MDAnalysis/GridDataFormats/blob/3eeb0432f8cf856912436e4f3e7aba99d3c916be/gridData/CCP4.py#L199-L216
[ "def", "read", "(", "self", ",", "filename", ")", ":", "if", "filename", "is", "not", "None", ":", "self", ".", "filename", "=", "filename", "with", "open", "(", "self", ".", "filename", ",", "'rb'", ")", "as", "ccp4", ":", "h", "=", "self", ".", ...
3eeb0432f8cf856912436e4f3e7aba99d3c916be
valid
CCP4._detect_byteorder
Detect the byteorder of stream `ccp4file` and return format character. Try all endinaness and alignment options until we find something that looks sensible ("MAPS " in the first 4 bytes). (The ``machst`` field could be used to obtain endianness, but it does not specify alignment.) ...
gridData/CCP4.py
def _detect_byteorder(ccp4file): """Detect the byteorder of stream `ccp4file` and return format character. Try all endinaness and alignment options until we find something that looks sensible ("MAPS " in the first 4 bytes). (The ``machst`` field could be used to obtain endianness, but ...
def _detect_byteorder(ccp4file): """Detect the byteorder of stream `ccp4file` and return format character. Try all endinaness and alignment options until we find something that looks sensible ("MAPS " in the first 4 bytes). (The ``machst`` field could be used to obtain endianness, but ...
[ "Detect", "the", "byteorder", "of", "stream", "ccp4file", "and", "return", "format", "character", "." ]
MDAnalysis/GridDataFormats
python
https://github.com/MDAnalysis/GridDataFormats/blob/3eeb0432f8cf856912436e4f3e7aba99d3c916be/gridData/CCP4.py#L240-L265
[ "def", "_detect_byteorder", "(", "ccp4file", ")", ":", "bsaflag", "=", "None", "ccp4file", ".", "seek", "(", "52", "*", "4", ")", "mapbin", "=", "ccp4file", ".", "read", "(", "4", ")", "for", "flag", "in", "'@=<>'", ":", "mapstr", "=", "struct", ".",...
3eeb0432f8cf856912436e4f3e7aba99d3c916be
valid
CCP4._read_header
Read header bytes
gridData/CCP4.py
def _read_header(self, ccp4file): """Read header bytes""" bsaflag = self._detect_byteorder(ccp4file) # Parse the top of the header (4-byte words, 1 to 25). nheader = struct.calcsize(self._headerfmt) names = [r.key for r in self._header_struct] bintopheader = ccp4file.re...
def _read_header(self, ccp4file): """Read header bytes""" bsaflag = self._detect_byteorder(ccp4file) # Parse the top of the header (4-byte words, 1 to 25). nheader = struct.calcsize(self._headerfmt) names = [r.key for r in self._header_struct] bintopheader = ccp4file.re...
[ "Read", "header", "bytes" ]
MDAnalysis/GridDataFormats
python
https://github.com/MDAnalysis/GridDataFormats/blob/3eeb0432f8cf856912436e4f3e7aba99d3c916be/gridData/CCP4.py#L267-L314
[ "def", "_read_header", "(", "self", ",", "ccp4file", ")", ":", "bsaflag", "=", "self", ".", "_detect_byteorder", "(", "ccp4file", ")", "# Parse the top of the header (4-byte words, 1 to 25).", "nheader", "=", "struct", ".", "calcsize", "(", "self", ".", "_headerfmt"...
3eeb0432f8cf856912436e4f3e7aba99d3c916be
valid
AmbientWeatherStation.get_data
Get the data for a specific device for a specific end date Keyword Arguments: limit - max 288 end_date - is Epoch in milliseconds :return:
ambient_api/ambientapi.py
def get_data(self, **kwargs): """ Get the data for a specific device for a specific end date Keyword Arguments: limit - max 288 end_date - is Epoch in milliseconds :return: """ limit = int(kwargs.get('limit', 288)) end_date = kwargs.get('...
def get_data(self, **kwargs): """ Get the data for a specific device for a specific end date Keyword Arguments: limit - max 288 end_date - is Epoch in milliseconds :return: """ limit = int(kwargs.get('limit', 288)) end_date = kwargs.get('...
[ "Get", "the", "data", "for", "a", "specific", "device", "for", "a", "specific", "end", "date" ]
avryhof/ambient_api
python
https://github.com/avryhof/ambient_api/blob/cb62a2127f3043bd4daba761725d579bfc762966/ambient_api/ambientapi.py#L54-L83
[ "def", "get_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "limit", "=", "int", "(", "kwargs", ".", "get", "(", "'limit'", ",", "288", ")", ")", "end_date", "=", "kwargs", ".", "get", "(", "'end_date'", ",", "False", ")", "if", "end_date", ...
cb62a2127f3043bd4daba761725d579bfc762966
valid
AmbientAPI.get_devices
Get all devices :return: A list of AmbientWeatherStation instances.
ambient_api/ambientapi.py
def get_devices(self): """ Get all devices :return: A list of AmbientWeatherStation instances. """ retn = [] api_devices = self.api_call('devices') self.log('DEVICES:') self.log(api_devices) for device in api_devices: ret...
def get_devices(self): """ Get all devices :return: A list of AmbientWeatherStation instances. """ retn = [] api_devices = self.api_call('devices') self.log('DEVICES:') self.log(api_devices) for device in api_devices: ret...
[ "Get", "all", "devices" ]
avryhof/ambient_api
python
https://github.com/avryhof/ambient_api/blob/cb62a2127f3043bd4daba761725d579bfc762966/ambient_api/ambientapi.py#L166-L185
[ "def", "get_devices", "(", "self", ")", ":", "retn", "=", "[", "]", "api_devices", "=", "self", ".", "api_call", "(", "'devices'", ")", "self", ".", "log", "(", "'DEVICES:'", ")", "self", ".", "log", "(", "api_devices", ")", "for", "device", "in", "a...
cb62a2127f3043bd4daba761725d579bfc762966
valid
UrlBuilder.create_url
Create URL with supplied path and `opts` parameters dict. Parameters ---------- path : str opts : dict Dictionary specifying URL parameters. Non-imgix parameters are added to the URL unprocessed. For a complete list of imgix supported parameters, visi...
imgix/urlbuilder.py
def create_url(self, path, params={}, opts={}): """ Create URL with supplied path and `opts` parameters dict. Parameters ---------- path : str opts : dict Dictionary specifying URL parameters. Non-imgix parameters are added to the URL unprocessed....
def create_url(self, path, params={}, opts={}): """ Create URL with supplied path and `opts` parameters dict. Parameters ---------- path : str opts : dict Dictionary specifying URL parameters. Non-imgix parameters are added to the URL unprocessed....
[ "Create", "URL", "with", "supplied", "path", "and", "opts", "parameters", "dict", "." ]
imgix/imgix-python
python
https://github.com/imgix/imgix-python/blob/117e0b169552695232689dd0443be7810263e5c5/imgix/urlbuilder.py#L95-L141
[ "def", "create_url", "(", "self", ",", "path", ",", "params", "=", "{", "}", ",", "opts", "=", "{", "}", ")", ":", "if", "opts", ":", "warnings", ".", "warn", "(", "'`opts` has been deprecated. Use `params` instead.'", ",", "DeprecationWarning", ",", "stackl...
117e0b169552695232689dd0443be7810263e5c5
valid
UrlHelper.set_parameter
Set a url parameter. Parameters ---------- key : str If key ends with '64', the value provided will be automatically base64 encoded.
imgix/urlhelper.py
def set_parameter(self, key, value): """ Set a url parameter. Parameters ---------- key : str If key ends with '64', the value provided will be automatically base64 encoded. """ if value is None or isinstance(value, (int, float, bool)): ...
def set_parameter(self, key, value): """ Set a url parameter. Parameters ---------- key : str If key ends with '64', the value provided will be automatically base64 encoded. """ if value is None or isinstance(value, (int, float, bool)): ...
[ "Set", "a", "url", "parameter", "." ]
imgix/imgix-python
python
https://github.com/imgix/imgix-python/blob/117e0b169552695232689dd0443be7810263e5c5/imgix/urlhelper.py#L75-L92
[ "def", "set_parameter", "(", "self", ",", "key", ",", "value", ")", ":", "if", "value", "is", "None", "or", "isinstance", "(", "value", ",", "(", "int", ",", "float", ",", "bool", ")", ")", ":", "value", "=", "str", "(", "value", ")", "if", "key"...
117e0b169552695232689dd0443be7810263e5c5
valid
Tibber.rt_connect
Start subscription manager for real time data.
tibber/__init__.py
async def rt_connect(self, loop): """Start subscription manager for real time data.""" if self.sub_manager is not None: return self.sub_manager = SubscriptionManager( loop, "token={}".format(self._access_token), SUB_ENDPOINT ) self.sub_manager.start()
async def rt_connect(self, loop): """Start subscription manager for real time data.""" if self.sub_manager is not None: return self.sub_manager = SubscriptionManager( loop, "token={}".format(self._access_token), SUB_ENDPOINT ) self.sub_manager.start()
[ "Start", "subscription", "manager", "for", "real", "time", "data", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L55-L62
[ "async", "def", "rt_connect", "(", "self", ",", "loop", ")", ":", "if", "self", ".", "sub_manager", "is", "not", "None", ":", "return", "self", ".", "sub_manager", "=", "SubscriptionManager", "(", "loop", ",", "\"token={}\"", ".", "format", "(", "self", ...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
Tibber.execute
Execute gql.
tibber/__init__.py
async def execute(self, document, variable_values=None): """Execute gql.""" res = await self._execute(document, variable_values) if res is None: return None return res.get("data")
async def execute(self, document, variable_values=None): """Execute gql.""" res = await self._execute(document, variable_values) if res is None: return None return res.get("data")
[ "Execute", "gql", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L70-L75
[ "async", "def", "execute", "(", "self", ",", "document", ",", "variable_values", "=", "None", ")", ":", "res", "=", "await", "self", ".", "_execute", "(", "document", ",", "variable_values", ")", "if", "res", "is", "None", ":", "return", "None", "return"...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
Tibber._execute
Execute gql.
tibber/__init__.py
async def _execute(self, document, variable_values=None, retry=2): """Execute gql.""" query_str = print_ast(document) payload = {"query": query_str, "variables": variable_values or {}} post_args = { "headers": {"Authorization": "Bearer " + self._access_token}, "d...
async def _execute(self, document, variable_values=None, retry=2): """Execute gql.""" query_str = print_ast(document) payload = {"query": query_str, "variables": variable_values or {}} post_args = { "headers": {"Authorization": "Bearer " + self._access_token}, "d...
[ "Execute", "gql", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L77-L109
[ "async", "def", "_execute", "(", "self", ",", "document", ",", "variable_values", "=", "None", ",", "retry", "=", "2", ")", ":", "query_str", "=", "print_ast", "(", "document", ")", "payload", "=", "{", "\"query\"", ":", "query_str", ",", "\"variables\"", ...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
Tibber.sync_update_info
Update home info.
tibber/__init__.py
def sync_update_info(self, *_): """Update home info.""" loop = asyncio.get_event_loop() task = loop.create_task(self.update_info()) loop.run_until_complete(task)
def sync_update_info(self, *_): """Update home info.""" loop = asyncio.get_event_loop() task = loop.create_task(self.update_info()) loop.run_until_complete(task)
[ "Update", "home", "info", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L111-L115
[ "def", "sync_update_info", "(", "self", ",", "*", "_", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "task", "=", "loop", ".", "create_task", "(", "self", ".", "update_info", "(", ")", ")", "loop", ".", "run_until_complete", "(", "...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
Tibber.update_info
Update home info async.
tibber/__init__.py
async def update_info(self, *_): """Update home info async.""" query = gql( """ { viewer { name homes { subscriptions { status } id } } } """ ) ...
async def update_info(self, *_): """Update home info async.""" query = gql( """ { viewer { name homes { subscriptions { status } id } } } """ ) ...
[ "Update", "home", "info", "async", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L117-L161
[ "async", "def", "update_info", "(", "self", ",", "*", "_", ")", ":", "query", "=", "gql", "(", "\"\"\"\n {\n viewer {\n name\n homes {\n subscriptions {\n status\n }\n id\n }\n ...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
Tibber.get_homes
Return list of Tibber homes.
tibber/__init__.py
def get_homes(self, only_active=True): """Return list of Tibber homes.""" return [self.get_home(home_id) for home_id in self.get_home_ids(only_active)]
def get_homes(self, only_active=True): """Return list of Tibber homes.""" return [self.get_home(home_id) for home_id in self.get_home_ids(only_active)]
[ "Return", "list", "of", "Tibber", "homes", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L179-L181
[ "def", "get_homes", "(", "self", ",", "only_active", "=", "True", ")", ":", "return", "[", "self", ".", "get_home", "(", "home_id", ")", "for", "home_id", "in", "self", ".", "get_home_ids", "(", "only_active", ")", "]" ]
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
Tibber.get_home
Retun an instance of TibberHome for given home id.
tibber/__init__.py
def get_home(self, home_id): """Retun an instance of TibberHome for given home id.""" if home_id not in self._all_home_ids: _LOGGER.error("Could not find any Tibber home with id: %s", home_id) return None if home_id not in self._homes.keys(): self._homes[home_...
def get_home(self, home_id): """Retun an instance of TibberHome for given home id.""" if home_id not in self._all_home_ids: _LOGGER.error("Could not find any Tibber home with id: %s", home_id) return None if home_id not in self._homes.keys(): self._homes[home_...
[ "Retun", "an", "instance", "of", "TibberHome", "for", "given", "home", "id", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L183-L190
[ "def", "get_home", "(", "self", ",", "home_id", ")", ":", "if", "home_id", "not", "in", "self", ".", "_all_home_ids", ":", "_LOGGER", ".", "error", "(", "\"Could not find any Tibber home with id: %s\"", ",", "home_id", ")", "return", "None", "if", "home_id", "...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
Tibber.send_notification
Send notification.
tibber/__init__.py
async def send_notification(self, title, message): """Send notification.""" query = gql( """ mutation{ sendPushNotification(input: { title: "%s", message: "%s", }){ successful pushedToNumberOfDevices } ...
async def send_notification(self, title, message): """Send notification.""" query = gql( """ mutation{ sendPushNotification(input: { title: "%s", message: "%s", }){ successful pushedToNumberOfDevices } ...
[ "Send", "notification", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L192-L220
[ "async", "def", "send_notification", "(", "self", ",", "title", ",", "message", ")", ":", "query", "=", "gql", "(", "\"\"\"\n mutation{\n sendPushNotification(input: {\n title: \"%s\",\n message: \"%s\",\n }){\n successful\n ...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
TibberHome.update_info
Update current price info async.
tibber/__init__.py
async def update_info(self): """Update current price info async.""" query = gql( """ { viewer { home(id: "%s") { appNickname features { realTimeConsumptionEnabled } currentSubscription {...
async def update_info(self): """Update current price info async.""" query = gql( """ { viewer { home(id: "%s") { appNickname features { realTimeConsumptionEnabled } currentSubscription {...
[ "Update", "current", "price", "info", "async", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L247-L309
[ "async", "def", "update_info", "(", "self", ")", ":", "query", "=", "gql", "(", "\"\"\"\n {\n viewer {\n home(id: \"%s\") {\n appNickname\n features {\n realTimeConsumptionEnabled\n }\n currentSub...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
TibberHome.sync_update_current_price_info
Update current price info.
tibber/__init__.py
def sync_update_current_price_info(self): """Update current price info.""" loop = asyncio.get_event_loop() task = loop.create_task(self.update_current_price_info()) loop.run_until_complete(task)
def sync_update_current_price_info(self): """Update current price info.""" loop = asyncio.get_event_loop() task = loop.create_task(self.update_current_price_info()) loop.run_until_complete(task)
[ "Update", "current", "price", "info", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L311-L315
[ "def", "sync_update_current_price_info", "(", "self", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "task", "=", "loop", ".", "create_task", "(", "self", ".", "update_current_price_info", "(", ")", ")", "loop", ".", "run_until_complete", "...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
TibberHome.update_current_price_info
Update current price info async.
tibber/__init__.py
async def update_current_price_info(self): """Update current price info async.""" query = gql( """ { viewer { home(id: "%s") { currentSubscription { priceInfo { current { energy ...
async def update_current_price_info(self): """Update current price info async.""" query = gql( """ { viewer { home(id: "%s") { currentSubscription { priceInfo { current { energy ...
[ "Update", "current", "price", "info", "async", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L317-L352
[ "async", "def", "update_current_price_info", "(", "self", ")", ":", "query", "=", "gql", "(", "\"\"\"\n {\n viewer {\n home(id: \"%s\") {\n currentSubscription {\n priceInfo {\n current {\n energy\n ...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
TibberHome.sync_update_price_info
Update current price info.
tibber/__init__.py
def sync_update_price_info(self): """Update current price info.""" loop = asyncio.get_event_loop() task = loop.create_task(self.update_price_info()) loop.run_until_complete(task)
def sync_update_price_info(self): """Update current price info.""" loop = asyncio.get_event_loop() task = loop.create_task(self.update_price_info()) loop.run_until_complete(task)
[ "Update", "current", "price", "info", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L354-L358
[ "def", "sync_update_price_info", "(", "self", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "task", "=", "loop", ".", "create_task", "(", "self", ".", "update_price_info", "(", ")", ")", "loop", ".", "run_until_complete", "(", "task", ...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
TibberHome.update_price_info
Update price info async.
tibber/__init__.py
async def update_price_info(self): """Update price info async.""" query = gql( """ { viewer { home(id: "%s") { currentSubscription { priceInfo { current { energy tax ...
async def update_price_info(self): """Update price info async.""" query = gql( """ { viewer { home(id: "%s") { currentSubscription { priceInfo { current { energy tax ...
[ "Update", "price", "info", "async", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L360-L413
[ "async", "def", "update_price_info", "(", "self", ")", ":", "query", "=", "gql", "(", "\"\"\"\n {\n viewer {\n home(id: \"%s\") {\n currentSubscription {\n priceInfo {\n current {\n energy\n ...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
TibberHome.currency
Return the currency.
tibber/__init__.py
def currency(self): """Return the currency.""" try: current_subscription = self.info["viewer"]["home"]["currentSubscription"] return current_subscription["priceInfo"]["current"]["currency"] except (KeyError, TypeError, IndexError): _LOGGER.error("Could not fin...
def currency(self): """Return the currency.""" try: current_subscription = self.info["viewer"]["home"]["currentSubscription"] return current_subscription["priceInfo"]["current"]["currency"] except (KeyError, TypeError, IndexError): _LOGGER.error("Could not fin...
[ "Return", "the", "currency", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L474-L481
[ "def", "currency", "(", "self", ")", ":", "try", ":", "current_subscription", "=", "self", ".", "info", "[", "\"viewer\"", "]", "[", "\"home\"", "]", "[", "\"currentSubscription\"", "]", "return", "current_subscription", "[", "\"priceInfo\"", "]", "[", "\"curr...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
TibberHome.price_unit
Return the price unit.
tibber/__init__.py
def price_unit(self): """Return the price unit.""" currency = self.currency consumption_unit = self.consumption_unit if not currency or not consumption_unit: _LOGGER.error("Could not find price_unit.") return " " return currency + "/" + consumption_unit
def price_unit(self): """Return the price unit.""" currency = self.currency consumption_unit = self.consumption_unit if not currency or not consumption_unit: _LOGGER.error("Could not find price_unit.") return " " return currency + "/" + consumption_unit
[ "Return", "the", "price", "unit", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L493-L500
[ "def", "price_unit", "(", "self", ")", ":", "currency", "=", "self", ".", "currency", "consumption_unit", "=", "self", ".", "consumption_unit", "if", "not", "currency", "or", "not", "consumption_unit", ":", "_LOGGER", ".", "error", "(", "\"Could not find price_u...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
TibberHome.rt_subscribe
Connect to Tibber and subscribe to Tibber rt subscription.
tibber/__init__.py
async def rt_subscribe(self, loop, async_callback): """Connect to Tibber and subscribe to Tibber rt subscription.""" if self._subscription_id is not None: _LOGGER.error("Already subscribed.") return await self._tibber_control.rt_connect(loop) document = gql( ...
async def rt_subscribe(self, loop, async_callback): """Connect to Tibber and subscribe to Tibber rt subscription.""" if self._subscription_id is not None: _LOGGER.error("Already subscribed.") return await self._tibber_control.rt_connect(loop) document = gql( ...
[ "Connect", "to", "Tibber", "and", "subscribe", "to", "Tibber", "rt", "subscription", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L502-L539
[ "async", "def", "rt_subscribe", "(", "self", ",", "loop", ",", "async_callback", ")", ":", "if", "self", ".", "_subscription_id", "is", "not", "None", ":", "_LOGGER", ".", "error", "(", "\"Already subscribed.\"", ")", "return", "await", "self", ".", "_tibber...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
TibberHome.rt_unsubscribe
Unsubscribe to Tibber rt subscription.
tibber/__init__.py
async def rt_unsubscribe(self): """Unsubscribe to Tibber rt subscription.""" if self._subscription_id is None: _LOGGER.error("Not subscribed.") return await self._tibber_control.sub_manager.unsubscribe(self._subscription_id)
async def rt_unsubscribe(self): """Unsubscribe to Tibber rt subscription.""" if self._subscription_id is None: _LOGGER.error("Not subscribed.") return await self._tibber_control.sub_manager.unsubscribe(self._subscription_id)
[ "Unsubscribe", "to", "Tibber", "rt", "subscription", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L541-L546
[ "async", "def", "rt_unsubscribe", "(", "self", ")", ":", "if", "self", ".", "_subscription_id", "is", "None", ":", "_LOGGER", ".", "error", "(", "\"Not subscribed.\"", ")", "return", "await", "self", ".", "_tibber_control", ".", "sub_manager", ".", "unsubscrib...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
TibberHome.rt_subscription_running
Is real time subscription running.
tibber/__init__.py
def rt_subscription_running(self): """Is real time subscription running.""" return ( self._tibber_control.sub_manager is not None and self._tibber_control.sub_manager.is_running and self._subscription_id is not None )
def rt_subscription_running(self): """Is real time subscription running.""" return ( self._tibber_control.sub_manager is not None and self._tibber_control.sub_manager.is_running and self._subscription_id is not None )
[ "Is", "real", "time", "subscription", "running", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L549-L555
[ "def", "rt_subscription_running", "(", "self", ")", ":", "return", "(", "self", ".", "_tibber_control", ".", "sub_manager", "is", "not", "None", "and", "self", ".", "_tibber_control", ".", "sub_manager", ".", "is_running", "and", "self", ".", "_subscription_id",...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
TibberHome.get_historic_data
Get historic data.
tibber/__init__.py
async def get_historic_data(self, n_data): """Get historic data.""" query = gql( """ { viewer { home(id: "%s") { consumption(resolution: HOURLY, last: %s) { nodes { f...
async def get_historic_data(self, n_data): """Get historic data.""" query = gql( """ { viewer { home(id: "%s") { consumption(resolution: HOURLY, last: %s) { nodes { f...
[ "Get", "historic", "data", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L557-L585
[ "async", "def", "get_historic_data", "(", "self", ",", "n_data", ")", ":", "query", "=", "gql", "(", "\"\"\"\n {\n viewer {\n home(id: \"%s\") {\n consumption(resolution: HOURLY, last: %s) {\n no...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
TibberHome.sync_get_historic_data
get_historic_data.
tibber/__init__.py
def sync_get_historic_data(self, n_data): """get_historic_data.""" loop = asyncio.get_event_loop() task = loop.create_task(self.get_historic_data(n_data)) loop.run_until_complete(task) return self._data
def sync_get_historic_data(self, n_data): """get_historic_data.""" loop = asyncio.get_event_loop() task = loop.create_task(self.get_historic_data(n_data)) loop.run_until_complete(task) return self._data
[ "get_historic_data", "." ]
Danielhiversen/pyTibber
python
https://github.com/Danielhiversen/pyTibber/blob/114ebc3dd49f6affd93665b0862d4cbdea03e9ef/tibber/__init__.py#L587-L592
[ "def", "sync_get_historic_data", "(", "self", ",", "n_data", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "task", "=", "loop", ".", "create_task", "(", "self", ".", "get_historic_data", "(", "n_data", ")", ")", "loop", ".", "run_until...
114ebc3dd49f6affd93665b0862d4cbdea03e9ef
valid
Activity.cleanup_none
Removes the temporary value set for None attributes.
microsoftbotframework/activity.py
def cleanup_none(self): """ Removes the temporary value set for None attributes. """ for (prop, default) in self.defaults.items(): if getattr(self, prop) == '_None': setattr(self, prop, None)
def cleanup_none(self): """ Removes the temporary value set for None attributes. """ for (prop, default) in self.defaults.items(): if getattr(self, prop) == '_None': setattr(self, prop, None)
[ "Removes", "the", "temporary", "value", "set", "for", "None", "attributes", "." ]
mbrown1508/microsoftbotframework
python
https://github.com/mbrown1508/microsoftbotframework/blob/427a2cab862a9d8de8faee190f36d0480d28b35f/microsoftbotframework/activity.py#L88-L94
[ "def", "cleanup_none", "(", "self", ")", ":", "for", "(", "prop", ",", "default", ")", "in", "self", ".", "defaults", ".", "items", "(", ")", ":", "if", "getattr", "(", "self", ",", "prop", ")", "==", "'_None'", ":", "setattr", "(", "self", ",", ...
427a2cab862a9d8de8faee190f36d0480d28b35f
valid
WSGIWorker.build_environ
Build the execution environment.
rocket/methods/wsgi.py
def build_environ(self, sock_file, conn): """ Build the execution environment. """ # Grab the request line request = self.read_request_line(sock_file) # Copy the Base Environment environ = self.base_environ.copy() # Grab the headers for k, v in self.read_headers...
def build_environ(self, sock_file, conn): """ Build the execution environment. """ # Grab the request line request = self.read_request_line(sock_file) # Copy the Base Environment environ = self.base_environ.copy() # Grab the headers for k, v in self.read_headers...
[ "Build", "the", "execution", "environment", "." ]
explorigin/Rocket
python
https://github.com/explorigin/Rocket/blob/53313677768159d13e6c2b7c69ad69ca59bb8c79/rocket/methods/wsgi.py#L62-L102
[ "def", "build_environ", "(", "self", ",", "sock_file", ",", "conn", ")", ":", "# Grab the request line", "request", "=", "self", ".", "read_request_line", "(", "sock_file", ")", "# Copy the Base Environment", "environ", "=", "self", ".", "base_environ", ".", "copy...
53313677768159d13e6c2b7c69ad69ca59bb8c79
valid
WSGIWorker.write
Write the data to the output socket.
rocket/methods/wsgi.py
def write(self, data, sections=None): """ Write the data to the output socket. """ if self.error[0]: self.status = self.error[0] data = b(self.error[1]) if not self.headers_sent: self.send_headers(data, sections) if self.request_method != 'HEAD': ...
def write(self, data, sections=None): """ Write the data to the output socket. """ if self.error[0]: self.status = self.error[0] data = b(self.error[1]) if not self.headers_sent: self.send_headers(data, sections) if self.request_method != 'HEAD': ...
[ "Write", "the", "data", "to", "the", "output", "socket", "." ]
explorigin/Rocket
python
https://github.com/explorigin/Rocket/blob/53313677768159d13e6c2b7c69ad69ca59bb8c79/rocket/methods/wsgi.py#L165-L186
[ "def", "write", "(", "self", ",", "data", ",", "sections", "=", "None", ")", ":", "if", "self", ".", "error", "[", "0", "]", ":", "self", ".", "status", "=", "self", ".", "error", "[", "0", "]", "data", "=", "b", "(", "self", ".", "error", "[...
53313677768159d13e6c2b7c69ad69ca59bb8c79
valid
WSGIWorker.start_response
Store the HTTP status and headers to be sent when self.write is called.
rocket/methods/wsgi.py
def start_response(self, status, response_headers, exc_info=None): """ Store the HTTP status and headers to be sent when self.write is called. """ if exc_info: try: if self.headers_sent: # Re-raise original exception if headers sent ...
def start_response(self, status, response_headers, exc_info=None): """ Store the HTTP status and headers to be sent when self.write is called. """ if exc_info: try: if self.headers_sent: # Re-raise original exception if headers sent ...
[ "Store", "the", "HTTP", "status", "and", "headers", "to", "be", "sent", "when", "self", ".", "write", "is", "called", "." ]
explorigin/Rocket
python
https://github.com/explorigin/Rocket/blob/53313677768159d13e6c2b7c69ad69ca59bb8c79/rocket/methods/wsgi.py#L188-L215
[ "def", "start_response", "(", "self", ",", "status", ",", "response_headers", ",", "exc_info", "=", "None", ")", ":", "if", "exc_info", ":", "try", ":", "if", "self", ".", "headers_sent", ":", "# Re-raise original exception if headers sent", "# because this violates...
53313677768159d13e6c2b7c69ad69ca59bb8c79
valid
CherryPyWSGIServer
A Cherrypy wsgiserver-compatible wrapper.
rocket/main.py
def CherryPyWSGIServer(bind_addr, wsgi_app, numthreads = 10, server_name = None, max = -1, request_queue_size = 5, timeout = 10, shutdown_timeout = 5): """...
def CherryPyWSGIServer(bind_addr, wsgi_app, numthreads = 10, server_name = None, max = -1, request_queue_size = 5, timeout = 10, shutdown_timeout = 5): """...
[ "A", "Cherrypy", "wsgiserver", "-", "compatible", "wrapper", "." ]
explorigin/Rocket
python
https://github.com/explorigin/Rocket/blob/53313677768159d13e6c2b7c69ad69ca59bb8c79/rocket/main.py#L198-L214
[ "def", "CherryPyWSGIServer", "(", "bind_addr", ",", "wsgi_app", ",", "numthreads", "=", "10", ",", "server_name", "=", "None", ",", "max", "=", "-", "1", ",", "request_queue_size", "=", "5", ",", "timeout", "=", "10", ",", "shutdown_timeout", "=", "5", "...
53313677768159d13e6c2b7c69ad69ca59bb8c79
valid
IOSXRDriver.get_bgp_neighbors
Initial run to figure out what VRF's are available Decided to get this one from Configured-section because bulk-getting all instance-data to do the same could get ridiculously heavy Assuming we're always interested in the DefaultVRF
napalm_iosxr/iosxr.py
def get_bgp_neighbors(self): def generate_vrf_query(vrf_name): """ Helper to provide XML-query for the VRF-type we're interested in. """ if vrf_name == "global": rpc_command = '<Get><Operational><BGP><InstanceTable><Instance><Naming>\ ...
def get_bgp_neighbors(self): def generate_vrf_query(vrf_name): """ Helper to provide XML-query for the VRF-type we're interested in. """ if vrf_name == "global": rpc_command = '<Get><Operational><BGP><InstanceTable><Instance><Naming>\ ...
[ "Initial", "run", "to", "figure", "out", "what", "VRF", "s", "are", "available", "Decided", "to", "get", "this", "one", "from", "Configured", "-", "section", "because", "bulk", "-", "getting", "all", "instance", "-", "data", "to", "do", "the", "same", "c...
napalm-automation/napalm-iosxr
python
https://github.com/napalm-automation/napalm-iosxr/blob/fd4b5ddd82026a7ed6518f17abe3069da981473a/napalm_iosxr/iosxr.py#L311-L449
[ "def", "get_bgp_neighbors", "(", "self", ")", ":", "def", "generate_vrf_query", "(", "vrf_name", ")", ":", "\"\"\"\n Helper to provide XML-query for the VRF-type we're interested in.\n \"\"\"", "if", "vrf_name", "==", "\"global\"", ":", "rpc_command", "=",...
fd4b5ddd82026a7ed6518f17abe3069da981473a
valid
aggregate
Aggregate a `list` of prefixes. Keyword arguments: l -- a python list of prefixes Example use: >>> aggregate(["10.0.0.0/8", "10.0.0.0/24"]) ['10.0.0.0/8']
aggregate6/aggregate6.py
def aggregate(l): """Aggregate a `list` of prefixes. Keyword arguments: l -- a python list of prefixes Example use: >>> aggregate(["10.0.0.0/8", "10.0.0.0/24"]) ['10.0.0.0/8'] """ tree = radix.Radix() for item in l: try: tree.add(item) except (ValueError...
def aggregate(l): """Aggregate a `list` of prefixes. Keyword arguments: l -- a python list of prefixes Example use: >>> aggregate(["10.0.0.0/8", "10.0.0.0/24"]) ['10.0.0.0/8'] """ tree = radix.Radix() for item in l: try: tree.add(item) except (ValueError...
[ "Aggregate", "a", "list", "of", "prefixes", "." ]
job/aggregate6
python
https://github.com/job/aggregate6/blob/fa93046a39e397795d6258ea4c46033dee3df69b/aggregate6/aggregate6.py#L44-L61
[ "def", "aggregate", "(", "l", ")", ":", "tree", "=", "radix", ".", "Radix", "(", ")", "for", "item", "in", "l", ":", "try", ":", "tree", ".", "add", "(", "item", ")", "except", "(", "ValueError", ")", "as", "err", ":", "raise", "Exception", "(", ...
fa93046a39e397795d6258ea4c46033dee3df69b
valid
aggregate_tree
Walk a py-radix tree and aggregate it. Arguments l_tree -- radix.Radix() object
aggregate6/aggregate6.py
def aggregate_tree(l_tree): """Walk a py-radix tree and aggregate it. Arguments l_tree -- radix.Radix() object """ def _aggregate_phase1(tree): # phase1 removes any supplied prefixes which are superfluous because # they are already included in another supplied prefix. For example, ...
def aggregate_tree(l_tree): """Walk a py-radix tree and aggregate it. Arguments l_tree -- radix.Radix() object """ def _aggregate_phase1(tree): # phase1 removes any supplied prefixes which are superfluous because # they are already included in another supplied prefix. For example, ...
[ "Walk", "a", "py", "-", "radix", "tree", "and", "aggregate", "it", "." ]
job/aggregate6
python
https://github.com/job/aggregate6/blob/fa93046a39e397795d6258ea4c46033dee3df69b/aggregate6/aggregate6.py#L64-L113
[ "def", "aggregate_tree", "(", "l_tree", ")", ":", "def", "_aggregate_phase1", "(", "tree", ")", ":", "# phase1 removes any supplied prefixes which are superfluous because", "# they are already included in another supplied prefix. For example,", "# 2001:67c:208c:10::/64 would be removed i...
fa93046a39e397795d6258ea4c46033dee3df69b
valid
_ordinal_metric
Metric for ordinal data.
krippendorff/krippendorff.py
def _ordinal_metric(_v1, _v2, i1, i2, n_v): """Metric for ordinal data.""" if i1 > i2: i1, i2 = i2, i1 return (np.sum(n_v[i1:(i2 + 1)]) - (n_v[i1] + n_v[i2]) / 2) ** 2
def _ordinal_metric(_v1, _v2, i1, i2, n_v): """Metric for ordinal data.""" if i1 > i2: i1, i2 = i2, i1 return (np.sum(n_v[i1:(i2 + 1)]) - (n_v[i1] + n_v[i2]) / 2) ** 2
[ "Metric", "for", "ordinal", "data", "." ]
pln-fing-udelar/fast-krippendorff
python
https://github.com/pln-fing-udelar/fast-krippendorff/blob/fbc983f206d41f76a6e8da8cabd7114941634420/krippendorff/krippendorff.py#L18-L22
[ "def", "_ordinal_metric", "(", "_v1", ",", "_v2", ",", "i1", ",", "i2", ",", "n_v", ")", ":", "if", "i1", ">", "i2", ":", "i1", ",", "i2", "=", "i2", ",", "i1", "return", "(", "np", ".", "sum", "(", "n_v", "[", "i1", ":", "(", "i2", "+", ...
fbc983f206d41f76a6e8da8cabd7114941634420
valid
_ratio_metric
Metric for ratio data.
krippendorff/krippendorff.py
def _ratio_metric(v1, v2, **_kwargs): """Metric for ratio data.""" return (((v1 - v2) / (v1 + v2)) ** 2) if v1 + v2 != 0 else 0
def _ratio_metric(v1, v2, **_kwargs): """Metric for ratio data.""" return (((v1 - v2) / (v1 + v2)) ** 2) if v1 + v2 != 0 else 0
[ "Metric", "for", "ratio", "data", "." ]
pln-fing-udelar/fast-krippendorff
python
https://github.com/pln-fing-udelar/fast-krippendorff/blob/fbc983f206d41f76a6e8da8cabd7114941634420/krippendorff/krippendorff.py#L30-L32
[ "def", "_ratio_metric", "(", "v1", ",", "v2", ",", "*", "*", "_kwargs", ")", ":", "return", "(", "(", "(", "v1", "-", "v2", ")", "/", "(", "v1", "+", "v2", ")", ")", "**", "2", ")", "if", "v1", "+", "v2", "!=", "0", "else", "0" ]
fbc983f206d41f76a6e8da8cabd7114941634420
valid
_coincidences
Coincidence matrix. Parameters ---------- value_counts : ndarray, with shape (N, V) Number of coders that assigned a certain value to a determined unit, where N is the number of units and V is the value count. value_domain : array_like, with shape (V,) Possible values V the uni...
krippendorff/krippendorff.py
def _coincidences(value_counts, value_domain, dtype=np.float64): """Coincidence matrix. Parameters ---------- value_counts : ndarray, with shape (N, V) Number of coders that assigned a certain value to a determined unit, where N is the number of units and V is the value count. valu...
def _coincidences(value_counts, value_domain, dtype=np.float64): """Coincidence matrix. Parameters ---------- value_counts : ndarray, with shape (N, V) Number of coders that assigned a certain value to a determined unit, where N is the number of units and V is the value count. valu...
[ "Coincidence", "matrix", "." ]
pln-fing-udelar/fast-krippendorff
python
https://github.com/pln-fing-udelar/fast-krippendorff/blob/fbc983f206d41f76a6e8da8cabd7114941634420/krippendorff/krippendorff.py#L35-L61
[ "def", "_coincidences", "(", "value_counts", ",", "value_domain", ",", "dtype", "=", "np", ".", "float64", ")", ":", "value_counts_matrices", "=", "value_counts", ".", "reshape", "(", "value_counts", ".", "shape", "+", "(", "1", ",", ")", ")", "pairable", ...
fbc983f206d41f76a6e8da8cabd7114941634420
valid
_random_coincidences
Random coincidence matrix. Parameters ---------- value_domain : array_like, with shape (V,) Possible values V the units can take. If the level of measurement is not nominal, it must be ordered. n : scalar Number of pairable values. n_v : ndarray, with shape (V,) Nu...
krippendorff/krippendorff.py
def _random_coincidences(value_domain, n, n_v): """Random coincidence matrix. Parameters ---------- value_domain : array_like, with shape (V,) Possible values V the units can take. If the level of measurement is not nominal, it must be ordered. n : scalar Number of pairable...
def _random_coincidences(value_domain, n, n_v): """Random coincidence matrix. Parameters ---------- value_domain : array_like, with shape (V,) Possible values V the units can take. If the level of measurement is not nominal, it must be ordered. n : scalar Number of pairable...
[ "Random", "coincidence", "matrix", "." ]
pln-fing-udelar/fast-krippendorff
python
https://github.com/pln-fing-udelar/fast-krippendorff/blob/fbc983f206d41f76a6e8da8cabd7114941634420/krippendorff/krippendorff.py#L64-L85
[ "def", "_random_coincidences", "(", "value_domain", ",", "n", ",", "n_v", ")", ":", "n_v_column", "=", "n_v", ".", "reshape", "(", "-", "1", ",", "1", ")", "return", "(", "n_v_column", ".", "dot", "(", "n_v_column", ".", "T", ")", "-", "np", ".", "...
fbc983f206d41f76a6e8da8cabd7114941634420
valid
_distances
Distances of the different possible values. Parameters ---------- value_domain : array_like, with shape (V,) Possible values V the units can take. If the level of measurement is not nominal, it must be ordered. distance_metric : callable Callable that return the distance of two...
krippendorff/krippendorff.py
def _distances(value_domain, distance_metric, n_v): """Distances of the different possible values. Parameters ---------- value_domain : array_like, with shape (V,) Possible values V the units can take. If the level of measurement is not nominal, it must be ordered. distance_metric ...
def _distances(value_domain, distance_metric, n_v): """Distances of the different possible values. Parameters ---------- value_domain : array_like, with shape (V,) Possible values V the units can take. If the level of measurement is not nominal, it must be ordered. distance_metric ...
[ "Distances", "of", "the", "different", "possible", "values", "." ]
pln-fing-udelar/fast-krippendorff
python
https://github.com/pln-fing-udelar/fast-krippendorff/blob/fbc983f206d41f76a6e8da8cabd7114941634420/krippendorff/krippendorff.py#L88-L110
[ "def", "_distances", "(", "value_domain", ",", "distance_metric", ",", "n_v", ")", ":", "return", "np", ".", "array", "(", "[", "[", "distance_metric", "(", "v1", ",", "v2", ",", "i1", "=", "i1", ",", "i2", "=", "i2", ",", "n_v", "=", "n_v", ")", ...
fbc983f206d41f76a6e8da8cabd7114941634420
valid
_reliability_data_to_value_counts
Return the value counts given the reliability data. Parameters ---------- reliability_data : ndarray, with shape (M, N) Reliability data matrix which has the rate the i coder gave to the j unit, where M is the number of raters and N is the unit count. Missing rates are represented w...
krippendorff/krippendorff.py
def _reliability_data_to_value_counts(reliability_data, value_domain): """Return the value counts given the reliability data. Parameters ---------- reliability_data : ndarray, with shape (M, N) Reliability data matrix which has the rate the i coder gave to the j unit, where M is the number of r...
def _reliability_data_to_value_counts(reliability_data, value_domain): """Return the value counts given the reliability data. Parameters ---------- reliability_data : ndarray, with shape (M, N) Reliability data matrix which has the rate the i coder gave to the j unit, where M is the number of r...
[ "Return", "the", "value", "counts", "given", "the", "reliability", "data", "." ]
pln-fing-udelar/fast-krippendorff
python
https://github.com/pln-fing-udelar/fast-krippendorff/blob/fbc983f206d41f76a6e8da8cabd7114941634420/krippendorff/krippendorff.py#L140-L159
[ "def", "_reliability_data_to_value_counts", "(", "reliability_data", ",", "value_domain", ")", ":", "return", "np", ".", "array", "(", "[", "[", "sum", "(", "1", "for", "rate", "in", "unit", "if", "rate", "==", "v", ")", "for", "v", "in", "value_domain", ...
fbc983f206d41f76a6e8da8cabd7114941634420
valid
alpha
Compute Krippendorff's alpha. See https://en.wikipedia.org/wiki/Krippendorff%27s_alpha for more information. Parameters ---------- reliability_data : array_like, with shape (M, N) Reliability data matrix which has the rate the i coder gave to the j unit, where M is the number of raters ...
krippendorff/krippendorff.py
def alpha(reliability_data=None, value_counts=None, value_domain=None, level_of_measurement='interval', dtype=np.float64): """Compute Krippendorff's alpha. See https://en.wikipedia.org/wiki/Krippendorff%27s_alpha for more information. Parameters ---------- reliability_data : array_like, ...
def alpha(reliability_data=None, value_counts=None, value_domain=None, level_of_measurement='interval', dtype=np.float64): """Compute Krippendorff's alpha. See https://en.wikipedia.org/wiki/Krippendorff%27s_alpha for more information. Parameters ---------- reliability_data : array_like, ...
[ "Compute", "Krippendorff", "s", "alpha", "." ]
pln-fing-udelar/fast-krippendorff
python
https://github.com/pln-fing-udelar/fast-krippendorff/blob/fbc983f206d41f76a6e8da8cabd7114941634420/krippendorff/krippendorff.py#L162-L261
[ "def", "alpha", "(", "reliability_data", "=", "None", ",", "value_counts", "=", "None", ",", "value_domain", "=", "None", ",", "level_of_measurement", "=", "'interval'", ",", "dtype", "=", "np", ".", "float64", ")", ":", "if", "(", "reliability_data", "is", ...
fbc983f206d41f76a6e8da8cabd7114941634420
valid
CDF.inquire
Maps to fortran CDF_Inquire. Assigns parameters returned by CDF_Inquire to pysatCDF instance. Not intended for regular direct use by user.
pysatCDF/_cdf.py
def inquire(self): """Maps to fortran CDF_Inquire. Assigns parameters returned by CDF_Inquire to pysatCDF instance. Not intended for regular direct use by user. """ name = copy.deepcopy(self.fname) stats = fortran_cdf.inquire(name) # break out fortran ...
def inquire(self): """Maps to fortran CDF_Inquire. Assigns parameters returned by CDF_Inquire to pysatCDF instance. Not intended for regular direct use by user. """ name = copy.deepcopy(self.fname) stats = fortran_cdf.inquire(name) # break out fortran ...
[ "Maps", "to", "fortran", "CDF_Inquire", "." ]
rstoneback/pysatCDF
python
https://github.com/rstoneback/pysatCDF/blob/479839f719dbece8e52d6bf6a466cb9506db6719/pysatCDF/_cdf.py#L113-L137
[ "def", "inquire", "(", "self", ")", ":", "name", "=", "copy", ".", "deepcopy", "(", "self", ".", "fname", ")", "stats", "=", "fortran_cdf", ".", "inquire", "(", "name", ")", "# break out fortran output into something meaningful", "status", "=", "stats", "[", ...
479839f719dbece8e52d6bf6a466cb9506db6719
valid
CDF._read_all_z_variable_info
Gets all CDF z-variable information, not data though. Maps to calls using var_inquire. Gets information on data type, number of elements, number of dimensions, etc.
pysatCDF/_cdf.py
def _read_all_z_variable_info(self): """Gets all CDF z-variable information, not data though. Maps to calls using var_inquire. Gets information on data type, number of elements, number of dimensions, etc. """ self.z_variable_info = {} self.z_variable_names_by_num = {} ...
def _read_all_z_variable_info(self): """Gets all CDF z-variable information, not data though. Maps to calls using var_inquire. Gets information on data type, number of elements, number of dimensions, etc. """ self.z_variable_info = {} self.z_variable_names_by_num = {} ...
[ "Gets", "all", "CDF", "z", "-", "variable", "information", "not", "data", "though", "." ]
rstoneback/pysatCDF
python
https://github.com/rstoneback/pysatCDF/blob/479839f719dbece8e52d6bf6a466cb9506db6719/pysatCDF/_cdf.py#L139-L184
[ "def", "_read_all_z_variable_info", "(", "self", ")", ":", "self", ".", "z_variable_info", "=", "{", "}", "self", ".", "z_variable_names_by_num", "=", "{", "}", "# call Fortran that grabs all of the basic stats on all of the", "# zVariables in one go.", "info", "=", "fort...
479839f719dbece8e52d6bf6a466cb9506db6719
valid
CDF.load_all_variables
Loads all variables from CDF. Note this routine is called automatically upon instantiation.
pysatCDF/_cdf.py
def load_all_variables(self): """Loads all variables from CDF. Note this routine is called automatically upon instantiation. """ self.data = {} # need to add r variable names file_var_names = self.z_variable_info.keys() # collect variabl...
def load_all_variables(self): """Loads all variables from CDF. Note this routine is called automatically upon instantiation. """ self.data = {} # need to add r variable names file_var_names = self.z_variable_info.keys() # collect variabl...
[ "Loads", "all", "variables", "from", "CDF", ".", "Note", "this", "routine", "is", "called", "automatically", "upon", "instantiation", "." ]
rstoneback/pysatCDF
python
https://github.com/rstoneback/pysatCDF/blob/479839f719dbece8e52d6bf6a466cb9506db6719/pysatCDF/_cdf.py#L186-L261
[ "def", "load_all_variables", "(", "self", ")", ":", "self", ".", "data", "=", "{", "}", "# need to add r variable names", "file_var_names", "=", "self", ".", "z_variable_info", ".", "keys", "(", ")", "# collect variable information for each", "# organize it neatly for f...
479839f719dbece8e52d6bf6a466cb9506db6719
valid
CDF._call_multi_fortran_z
Calls fortran functions to load CDF variable data Parameters ---------- names : list_like list of variables names data_types : list_like list of all loaded data type codes as used by CDF rec_nums : list_like list of record numbers in CDF file....
pysatCDF/_cdf.py
def _call_multi_fortran_z(self, names, data_types, rec_nums, dim_sizes, input_type_code, func, epoch=False, data_offset=None, epoch16=False): """Calls fortran functions to load CDF variable data Parameters ---------- names : li...
def _call_multi_fortran_z(self, names, data_types, rec_nums, dim_sizes, input_type_code, func, epoch=False, data_offset=None, epoch16=False): """Calls fortran functions to load CDF variable data Parameters ---------- names : li...
[ "Calls", "fortran", "functions", "to", "load", "CDF", "variable", "data" ]
rstoneback/pysatCDF
python
https://github.com/rstoneback/pysatCDF/blob/479839f719dbece8e52d6bf6a466cb9506db6719/pysatCDF/_cdf.py#L263-L325
[ "def", "_call_multi_fortran_z", "(", "self", ",", "names", ",", "data_types", ",", "rec_nums", ",", "dim_sizes", ",", "input_type_code", ",", "func", ",", "epoch", "=", "False", ",", "data_offset", "=", "None", ",", "epoch16", "=", "False", ")", ":", "# is...
479839f719dbece8e52d6bf6a466cb9506db6719
valid
CDF._process_return_multi_z
process and attach data from fortran_cdf.get_multi_*
pysatCDF/_cdf.py
def _process_return_multi_z(self, data, names, dim_sizes): """process and attach data from fortran_cdf.get_multi_*""" # process data d1 = 0 d2 = 0 for name, dim_size in zip(names, dim_sizes): d2 = d1 + dim_size if dim_size == 1: self.data[n...
def _process_return_multi_z(self, data, names, dim_sizes): """process and attach data from fortran_cdf.get_multi_*""" # process data d1 = 0 d2 = 0 for name, dim_size in zip(names, dim_sizes): d2 = d1 + dim_size if dim_size == 1: self.data[n...
[ "process", "and", "attach", "data", "from", "fortran_cdf", ".", "get_multi_", "*" ]
rstoneback/pysatCDF
python
https://github.com/rstoneback/pysatCDF/blob/479839f719dbece8e52d6bf6a466cb9506db6719/pysatCDF/_cdf.py#L327-L338
[ "def", "_process_return_multi_z", "(", "self", ",", "data", ",", "names", ",", "dim_sizes", ")", ":", "# process data", "d1", "=", "0", "d2", "=", "0", "for", "name", ",", "dim_size", "in", "zip", "(", "names", ",", "dim_sizes", ")", ":", "d2", "=", ...
479839f719dbece8e52d6bf6a466cb9506db6719
valid
CDF._read_all_attribute_info
Read all attribute properties, g, r, and z attributes
pysatCDF/_cdf.py
def _read_all_attribute_info(self): """Read all attribute properties, g, r, and z attributes""" num = copy.deepcopy(self._num_attrs) fname = copy.deepcopy(self.fname) out = fortran_cdf.inquire_all_attr(fname, num, len(fname)) status = out[0] names = out[1].astype('U') ...
def _read_all_attribute_info(self): """Read all attribute properties, g, r, and z attributes""" num = copy.deepcopy(self._num_attrs) fname = copy.deepcopy(self.fname) out = fortran_cdf.inquire_all_attr(fname, num, len(fname)) status = out[0] names = out[1].astype('U') ...
[ "Read", "all", "attribute", "properties", "g", "r", "and", "z", "attributes" ]
rstoneback/pysatCDF
python
https://github.com/rstoneback/pysatCDF/blob/479839f719dbece8e52d6bf6a466cb9506db6719/pysatCDF/_cdf.py#L340-L378
[ "def", "_read_all_attribute_info", "(", "self", ")", ":", "num", "=", "copy", ".", "deepcopy", "(", "self", ".", "_num_attrs", ")", "fname", "=", "copy", ".", "deepcopy", "(", "self", ".", "fname", ")", "out", "=", "fortran_cdf", ".", "inquire_all_attr", ...
479839f719dbece8e52d6bf6a466cb9506db6719
valid
CDF._read_all_z_attribute_data
Read all CDF z-attribute data
pysatCDF/_cdf.py
def _read_all_z_attribute_data(self): """Read all CDF z-attribute data""" self.meta = {} # collect attribute info needed to get more info from # fortran routines max_entries = [] attr_nums = [] names = [] attr_names = [] names = self.var_attrs_inf...
def _read_all_z_attribute_data(self): """Read all CDF z-attribute data""" self.meta = {} # collect attribute info needed to get more info from # fortran routines max_entries = [] attr_nums = [] names = [] attr_names = [] names = self.var_attrs_inf...
[ "Read", "all", "CDF", "z", "-", "attribute", "data" ]
rstoneback/pysatCDF
python
https://github.com/rstoneback/pysatCDF/blob/479839f719dbece8e52d6bf6a466cb9506db6719/pysatCDF/_cdf.py#L380-L485
[ "def", "_read_all_z_attribute_data", "(", "self", ")", ":", "self", ".", "meta", "=", "{", "}", "# collect attribute info needed to get more info from ", "# fortran routines", "max_entries", "=", "[", "]", "attr_nums", "=", "[", "]", "names", "=", "[", "]", "attr_...
479839f719dbece8e52d6bf6a466cb9506db6719
valid
CDF._call_multi_fortran_z_attr
Calls Fortran function that reads attribute data. data_offset translates unsigned into signed. If number read in is negative, offset added.
pysatCDF/_cdf.py
def _call_multi_fortran_z_attr(self, names, data_types, num_elems, entry_nums, attr_nums, var_names, input_type_code, func, data_offset=None): """Calls Fortran function that reads attribute data. data_offset translates unsign...
def _call_multi_fortran_z_attr(self, names, data_types, num_elems, entry_nums, attr_nums, var_names, input_type_code, func, data_offset=None): """Calls Fortran function that reads attribute data. data_offset translates unsign...
[ "Calls", "Fortran", "function", "that", "reads", "attribute", "data", ".", "data_offset", "translates", "unsigned", "into", "signed", ".", "If", "number", "read", "in", "is", "negative", "offset", "added", "." ]
rstoneback/pysatCDF
python
https://github.com/rstoneback/pysatCDF/blob/479839f719dbece8e52d6bf6a466cb9506db6719/pysatCDF/_cdf.py#L487-L521
[ "def", "_call_multi_fortran_z_attr", "(", "self", ",", "names", ",", "data_types", ",", "num_elems", ",", "entry_nums", ",", "attr_nums", ",", "var_names", ",", "input_type_code", ",", "func", ",", "data_offset", "=", "None", ")", ":", "# isolate input type code v...
479839f719dbece8e52d6bf6a466cb9506db6719
valid
CDF._process_return_multi_z_attr
process and attach data from fortran_cdf.get_multi_*
pysatCDF/_cdf.py
def _process_return_multi_z_attr(self, data, attr_names, var_names, sub_num_elems): '''process and attach data from fortran_cdf.get_multi_*''' # process data for i, (attr_name, var_name, num_e) in enumerate(zip(attr_names, var_names, sub_num_elems)): if var_name not in self.meta.key...
def _process_return_multi_z_attr(self, data, attr_names, var_names, sub_num_elems): '''process and attach data from fortran_cdf.get_multi_*''' # process data for i, (attr_name, var_name, num_e) in enumerate(zip(attr_names, var_names, sub_num_elems)): if var_name not in self.meta.key...
[ "process", "and", "attach", "data", "from", "fortran_cdf", ".", "get_multi_", "*" ]
rstoneback/pysatCDF
python
https://github.com/rstoneback/pysatCDF/blob/479839f719dbece8e52d6bf6a466cb9506db6719/pysatCDF/_cdf.py#L523-L536
[ "def", "_process_return_multi_z_attr", "(", "self", ",", "data", ",", "attr_names", ",", "var_names", ",", "sub_num_elems", ")", ":", "# process data", "for", "i", ",", "(", "attr_name", ",", "var_name", ",", "num_e", ")", "in", "enumerate", "(", "zip", "(",...
479839f719dbece8e52d6bf6a466cb9506db6719
valid
CDF.to_pysat
Exports loaded CDF data into data, meta for pysat module Notes ----- The *_labels should be set to the values in the file, if present. Note that once the meta object returned from this function is attached to a pysat.Instrument object then the *_labels on the Instrument ...
pysatCDF/_cdf.py
def to_pysat(self, flatten_twod=True, units_label='UNITS', name_label='long_name', fill_label='FILLVAL', plot_label='FieldNam', min_label='ValidMin', max_label='ValidMax', notes_label='Var_Notes', desc_label='CatDesc', axi...
def to_pysat(self, flatten_twod=True, units_label='UNITS', name_label='long_name', fill_label='FILLVAL', plot_label='FieldNam', min_label='ValidMin', max_label='ValidMax', notes_label='Var_Notes', desc_label='CatDesc', axi...
[ "Exports", "loaded", "CDF", "data", "into", "data", "meta", "for", "pysat", "module", "Notes", "-----", "The", "*", "_labels", "should", "be", "set", "to", "the", "values", "in", "the", "file", "if", "present", ".", "Note", "that", "once", "the", "meta",...
rstoneback/pysatCDF
python
https://github.com/rstoneback/pysatCDF/blob/479839f719dbece8e52d6bf6a466cb9506db6719/pysatCDF/_cdf.py#L538-L667
[ "def", "to_pysat", "(", "self", ",", "flatten_twod", "=", "True", ",", "units_label", "=", "'UNITS'", ",", "name_label", "=", "'long_name'", ",", "fill_label", "=", "'FILLVAL'", ",", "plot_label", "=", "'FieldNam'", ",", "min_label", "=", "'ValidMin'", ",", ...
479839f719dbece8e52d6bf6a466cb9506db6719
valid
_uptime_linux
Returns uptime in seconds or None, on Linux.
src/__init__.py
def _uptime_linux(): """Returns uptime in seconds or None, on Linux.""" # With procfs try: f = open('/proc/uptime', 'r') up = float(f.readline().split()[0]) f.close() return up except (IOError, ValueError): pass # Without procfs (really?) try: lib...
def _uptime_linux(): """Returns uptime in seconds or None, on Linux.""" # With procfs try: f = open('/proc/uptime', 'r') up = float(f.readline().split()[0]) f.close() return up except (IOError, ValueError): pass # Without procfs (really?) try: lib...
[ "Returns", "uptime", "in", "seconds", "or", "None", "on", "Linux", "." ]
Cairnarvon/uptime
python
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L56-L95
[ "def", "_uptime_linux", "(", ")", ":", "# With procfs", "try", ":", "f", "=", "open", "(", "'/proc/uptime'", ",", "'r'", ")", "up", "=", "float", "(", "f", ".", "readline", "(", ")", ".", "split", "(", ")", "[", "0", "]", ")", "f", ".", "close", ...
1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb
valid
_boottime_linux
A way to figure out the boot time directly on Linux.
src/__init__.py
def _boottime_linux(): """A way to figure out the boot time directly on Linux.""" global __boottime try: f = open('/proc/stat', 'r') for line in f: if line.startswith('btime'): __boottime = int(line.split()[1]) if datetime is None: raise NotIm...
def _boottime_linux(): """A way to figure out the boot time directly on Linux.""" global __boottime try: f = open('/proc/stat', 'r') for line in f: if line.startswith('btime'): __boottime = int(line.split()[1]) if datetime is None: raise NotIm...
[ "A", "way", "to", "figure", "out", "the", "boot", "time", "directly", "on", "Linux", "." ]
Cairnarvon/uptime
python
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L97-L111
[ "def", "_boottime_linux", "(", ")", ":", "global", "__boottime", "try", ":", "f", "=", "open", "(", "'/proc/stat'", ",", "'r'", ")", "for", "line", "in", "f", ":", "if", "line", ".", "startswith", "(", "'btime'", ")", ":", "__boottime", "=", "int", "...
1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb
valid
_uptime_amiga
Returns uptime in seconds or None, on AmigaOS.
src/__init__.py
def _uptime_amiga(): """Returns uptime in seconds or None, on AmigaOS.""" global __boottime try: __boottime = os.stat('RAM:').st_ctime return time.time() - __boottime except (NameError, OSError): return None
def _uptime_amiga(): """Returns uptime in seconds or None, on AmigaOS.""" global __boottime try: __boottime = os.stat('RAM:').st_ctime return time.time() - __boottime except (NameError, OSError): return None
[ "Returns", "uptime", "in", "seconds", "or", "None", "on", "AmigaOS", "." ]
Cairnarvon/uptime
python
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L113-L120
[ "def", "_uptime_amiga", "(", ")", ":", "global", "__boottime", "try", ":", "__boottime", "=", "os", ".", "stat", "(", "'RAM:'", ")", ".", "st_ctime", "return", "time", ".", "time", "(", ")", "-", "__boottime", "except", "(", "NameError", ",", "OSError", ...
1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb
valid
_uptime_beos
Returns uptime in seconds on None, on BeOS/Haiku.
src/__init__.py
def _uptime_beos(): """Returns uptime in seconds on None, on BeOS/Haiku.""" try: libroot = ctypes.CDLL('libroot.so') except (AttributeError, OSError): return None if not hasattr(libroot, 'system_time'): return None libroot.system_time.restype = ctypes.c_int64 return lib...
def _uptime_beos(): """Returns uptime in seconds on None, on BeOS/Haiku.""" try: libroot = ctypes.CDLL('libroot.so') except (AttributeError, OSError): return None if not hasattr(libroot, 'system_time'): return None libroot.system_time.restype = ctypes.c_int64 return lib...
[ "Returns", "uptime", "in", "seconds", "on", "None", "on", "BeOS", "/", "Haiku", "." ]
Cairnarvon/uptime
python
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L122-L133
[ "def", "_uptime_beos", "(", ")", ":", "try", ":", "libroot", "=", "ctypes", ".", "CDLL", "(", "'libroot.so'", ")", "except", "(", "AttributeError", ",", "OSError", ")", ":", "return", "None", "if", "not", "hasattr", "(", "libroot", ",", "'system_time'", ...
1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb
valid
_uptime_bsd
Returns uptime in seconds or None, on BSD (including OS X).
src/__init__.py
def _uptime_bsd(): """Returns uptime in seconds or None, on BSD (including OS X).""" global __boottime try: libc = ctypes.CDLL('libc.so') except AttributeError: return None except OSError: # OS X; can't use ctypes.util.find_library because that creates # a new process...
def _uptime_bsd(): """Returns uptime in seconds or None, on BSD (including OS X).""" global __boottime try: libc = ctypes.CDLL('libc.so') except AttributeError: return None except OSError: # OS X; can't use ctypes.util.find_library because that creates # a new process...
[ "Returns", "uptime", "in", "seconds", "or", "None", "on", "BSD", "(", "including", "OS", "X", ")", "." ]
Cairnarvon/uptime
python
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L135-L174
[ "def", "_uptime_bsd", "(", ")", ":", "global", "__boottime", "try", ":", "libc", "=", "ctypes", ".", "CDLL", "(", "'libc.so'", ")", "except", "AttributeError", ":", "return", "None", "except", "OSError", ":", "# OS X; can't use ctypes.util.find_library because that ...
1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb
valid
_uptime_minix
Returns uptime in seconds or None, on MINIX.
src/__init__.py
def _uptime_minix(): """Returns uptime in seconds or None, on MINIX.""" try: f = open('/proc/uptime', 'r') up = float(f.read()) f.close() return up except (IOError, ValueError): return None
def _uptime_minix(): """Returns uptime in seconds or None, on MINIX.""" try: f = open('/proc/uptime', 'r') up = float(f.read()) f.close() return up except (IOError, ValueError): return None
[ "Returns", "uptime", "in", "seconds", "or", "None", "on", "MINIX", "." ]
Cairnarvon/uptime
python
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L188-L196
[ "def", "_uptime_minix", "(", ")", ":", "try", ":", "f", "=", "open", "(", "'/proc/uptime'", ",", "'r'", ")", "up", "=", "float", "(", "f", ".", "read", "(", ")", ")", "f", ".", "close", "(", ")", "return", "up", "except", "(", "IOError", ",", "...
1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb
valid
_uptime_plan9
Returns uptime in seconds or None, on Plan 9.
src/__init__.py
def _uptime_plan9(): """Returns uptime in seconds or None, on Plan 9.""" # Apparently Plan 9 only has Python 2.2, which I'm not prepared to # support. Maybe some Linuxes implement /dev/time, though, someone was # talking about it somewhere. try: # The time file holds one 32-bit number repres...
def _uptime_plan9(): """Returns uptime in seconds or None, on Plan 9.""" # Apparently Plan 9 only has Python 2.2, which I'm not prepared to # support. Maybe some Linuxes implement /dev/time, though, someone was # talking about it somewhere. try: # The time file holds one 32-bit number repres...
[ "Returns", "uptime", "in", "seconds", "or", "None", "on", "Plan", "9", "." ]
Cairnarvon/uptime
python
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L198-L214
[ "def", "_uptime_plan9", "(", ")", ":", "# Apparently Plan 9 only has Python 2.2, which I'm not prepared to", "# support. Maybe some Linuxes implement /dev/time, though, someone was", "# talking about it somewhere.", "try", ":", "# The time file holds one 32-bit number representing the sec-", "...
1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb
valid
_uptime_solaris
Returns uptime in seconds or None, on Solaris.
src/__init__.py
def _uptime_solaris(): """Returns uptime in seconds or None, on Solaris.""" global __boottime try: kstat = ctypes.CDLL('libkstat.so') except (AttributeError, OSError): return None # kstat doesn't have uptime, but it does have boot time. # Unfortunately, getting at it isn't perfe...
def _uptime_solaris(): """Returns uptime in seconds or None, on Solaris.""" global __boottime try: kstat = ctypes.CDLL('libkstat.so') except (AttributeError, OSError): return None # kstat doesn't have uptime, but it does have boot time. # Unfortunately, getting at it isn't perfe...
[ "Returns", "uptime", "in", "seconds", "or", "None", "on", "Solaris", "." ]
Cairnarvon/uptime
python
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L227-L290
[ "def", "_uptime_solaris", "(", ")", ":", "global", "__boottime", "try", ":", "kstat", "=", "ctypes", ".", "CDLL", "(", "'libkstat.so'", ")", "except", "(", "AttributeError", ",", "OSError", ")", ":", "return", "None", "# kstat doesn't have uptime, but it does have...
1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb
valid
_uptime_syllable
Returns uptime in seconds or None, on Syllable.
src/__init__.py
def _uptime_syllable(): """Returns uptime in seconds or None, on Syllable.""" global __boottime try: __boottime = os.stat('/dev/pty/mst/pty0').st_mtime return time.time() - __boottime except (NameError, OSError): return None
def _uptime_syllable(): """Returns uptime in seconds or None, on Syllable.""" global __boottime try: __boottime = os.stat('/dev/pty/mst/pty0').st_mtime return time.time() - __boottime except (NameError, OSError): return None
[ "Returns", "uptime", "in", "seconds", "or", "None", "on", "Syllable", "." ]
Cairnarvon/uptime
python
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L292-L299
[ "def", "_uptime_syllable", "(", ")", ":", "global", "__boottime", "try", ":", "__boottime", "=", "os", ".", "stat", "(", "'/dev/pty/mst/pty0'", ")", ".", "st_mtime", "return", "time", ".", "time", "(", ")", "-", "__boottime", "except", "(", "NameError", ",...
1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb
valid
_uptime_windows
Returns uptime in seconds or None, on Windows. Warning: may return incorrect answers after 49.7 days on versions older than Vista.
src/__init__.py
def _uptime_windows(): """ Returns uptime in seconds or None, on Windows. Warning: may return incorrect answers after 49.7 days on versions older than Vista. """ if hasattr(ctypes, 'windll') and hasattr(ctypes.windll, 'kernel32'): lib = ctypes.windll.kernel32 else: try: ...
def _uptime_windows(): """ Returns uptime in seconds or None, on Windows. Warning: may return incorrect answers after 49.7 days on versions older than Vista. """ if hasattr(ctypes, 'windll') and hasattr(ctypes.windll, 'kernel32'): lib = ctypes.windll.kernel32 else: try: ...
[ "Returns", "uptime", "in", "seconds", "or", "None", "on", "Windows", ".", "Warning", ":", "may", "return", "incorrect", "answers", "after", "49", ".", "7", "days", "on", "versions", "older", "than", "Vista", "." ]
Cairnarvon/uptime
python
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L301-L323
[ "def", "_uptime_windows", "(", ")", ":", "if", "hasattr", "(", "ctypes", ",", "'windll'", ")", "and", "hasattr", "(", "ctypes", ".", "windll", ",", "'kernel32'", ")", ":", "lib", "=", "ctypes", ".", "windll", ".", "kernel32", "else", ":", "try", ":", ...
1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb
valid
uptime
Returns uptime in seconds if even remotely possible, or None if not.
src/__init__.py
def uptime(): """Returns uptime in seconds if even remotely possible, or None if not.""" if __boottime is not None: return time.time() - __boottime return {'amiga': _uptime_amiga, 'aros12': _uptime_amiga, 'beos5': _uptime_beos, 'cygwin': _uptime_linux, ...
def uptime(): """Returns uptime in seconds if even remotely possible, or None if not.""" if __boottime is not None: return time.time() - __boottime return {'amiga': _uptime_amiga, 'aros12': _uptime_amiga, 'beos5': _uptime_beos, 'cygwin': _uptime_linux, ...
[ "Returns", "uptime", "in", "seconds", "if", "even", "remotely", "possible", "or", "None", "if", "not", "." ]
Cairnarvon/uptime
python
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L325-L349
[ "def", "uptime", "(", ")", ":", "if", "__boottime", "is", "not", "None", ":", "return", "time", ".", "time", "(", ")", "-", "__boottime", "return", "{", "'amiga'", ":", "_uptime_amiga", ",", "'aros12'", ":", "_uptime_amiga", ",", "'beos5'", ":", "_uptime...
1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb
valid
boottime
Returns boot time if remotely possible, or None if not.
src/__init__.py
def boottime(): """Returns boot time if remotely possible, or None if not.""" global __boottime if __boottime is None: up = uptime() if up is None: return None if __boottime is None: _boottime_linux() if datetime is None: raise RuntimeError('datetime mod...
def boottime(): """Returns boot time if remotely possible, or None if not.""" global __boottime if __boottime is None: up = uptime() if up is None: return None if __boottime is None: _boottime_linux() if datetime is None: raise RuntimeError('datetime mod...
[ "Returns", "boot", "time", "if", "remotely", "possible", "or", "None", "if", "not", "." ]
Cairnarvon/uptime
python
https://github.com/Cairnarvon/uptime/blob/1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb/src/__init__.py#L351-L365
[ "def", "boottime", "(", ")", ":", "global", "__boottime", "if", "__boottime", "is", "None", ":", "up", "=", "uptime", "(", ")", "if", "up", "is", "None", ":", "return", "None", "if", "__boottime", "is", "None", ":", "_boottime_linux", "(", ")", "if", ...
1ddfd06bb300c00e6dc4bd2a9ddf9bf1aa27b1bb
valid
_initfile
Initialize an empty JSON file.
livejson.py
def _initfile(path, data="dict"): """Initialize an empty JSON file.""" data = {} if data.lower() == "dict" else [] # The file will need to be created if it doesn't exist if not os.path.exists(path): # The file doesn't exist # Raise exception if the directory that should contain the file doesn't...
def _initfile(path, data="dict"): """Initialize an empty JSON file.""" data = {} if data.lower() == "dict" else [] # The file will need to be created if it doesn't exist if not os.path.exists(path): # The file doesn't exist # Raise exception if the directory that should contain the file doesn't...
[ "Initialize", "an", "empty", "JSON", "file", "." ]
controversial/livejson
python
https://github.com/controversial/livejson/blob/91021de60903d2d8b2cfb7d8d8910bcf27ec003b/livejson.py#L19-L40
[ "def", "_initfile", "(", "path", ",", "data", "=", "\"dict\"", ")", ":", "data", "=", "{", "}", "if", "data", ".", "lower", "(", ")", "==", "\"dict\"", "else", "[", "]", "# The file will need to be created if it doesn't exist", "if", "not", "os", ".", "pat...
91021de60903d2d8b2cfb7d8d8910bcf27ec003b
valid
_BaseFile._data
A simpler version of data to avoid infinite recursion in some cases. Don't use this.
livejson.py
def _data(self): """A simpler version of data to avoid infinite recursion in some cases. Don't use this. """ if self.is_caching: return self.cache with open(self.path, "r") as f: return json.load(f)
def _data(self): """A simpler version of data to avoid infinite recursion in some cases. Don't use this. """ if self.is_caching: return self.cache with open(self.path, "r") as f: return json.load(f)
[ "A", "simpler", "version", "of", "data", "to", "avoid", "infinite", "recursion", "in", "some", "cases", "." ]
controversial/livejson
python
https://github.com/controversial/livejson/blob/91021de60903d2d8b2cfb7d8d8910bcf27ec003b/livejson.py#L195-L203
[ "def", "_data", "(", "self", ")", ":", "if", "self", ".", "is_caching", ":", "return", "self", ".", "cache", "with", "open", "(", "self", ".", "path", ",", "\"r\"", ")", "as", "f", ":", "return", "json", ".", "load", "(", "f", ")" ]
91021de60903d2d8b2cfb7d8d8910bcf27ec003b
valid
_BaseFile.data
Overwrite the file with new data. You probably shouldn't do this yourself, it's easy to screw up your whole file with this.
livejson.py
def data(self, data): """Overwrite the file with new data. You probably shouldn't do this yourself, it's easy to screw up your whole file with this.""" if self.is_caching: self.cache = data else: fcontents = self.file_contents with open(self.path, "w")...
def data(self, data): """Overwrite the file with new data. You probably shouldn't do this yourself, it's easy to screw up your whole file with this.""" if self.is_caching: self.cache = data else: fcontents = self.file_contents with open(self.path, "w")...
[ "Overwrite", "the", "file", "with", "new", "data", ".", "You", "probably", "shouldn", "t", "do", "this", "yourself", "it", "s", "easy", "to", "screw", "up", "your", "whole", "file", "with", "this", "." ]
controversial/livejson
python
https://github.com/controversial/livejson/blob/91021de60903d2d8b2cfb7d8d8910bcf27ec003b/livejson.py#L214-L233
[ "def", "data", "(", "self", ",", "data", ")", ":", "if", "self", ".", "is_caching", ":", "self", ".", "cache", "=", "data", "else", ":", "fcontents", "=", "self", ".", "file_contents", "with", "open", "(", "self", ".", "path", ",", "\"w\"", ")", "a...
91021de60903d2d8b2cfb7d8d8910bcf27ec003b
valid
_BaseFile._updateType
Make sure that the class behaves like the data structure that it is, so that we don't get a ListFile trying to represent a dict.
livejson.py
def _updateType(self): """Make sure that the class behaves like the data structure that it is, so that we don't get a ListFile trying to represent a dict.""" data = self._data() # Change type if needed if isinstance(data, dict) and isinstance(self, ListFile): self.__c...
def _updateType(self): """Make sure that the class behaves like the data structure that it is, so that we don't get a ListFile trying to represent a dict.""" data = self._data() # Change type if needed if isinstance(data, dict) and isinstance(self, ListFile): self.__c...
[ "Make", "sure", "that", "the", "class", "behaves", "like", "the", "data", "structure", "that", "it", "is", "so", "that", "we", "don", "t", "get", "a", "ListFile", "trying", "to", "represent", "a", "dict", "." ]
controversial/livejson
python
https://github.com/controversial/livejson/blob/91021de60903d2d8b2cfb7d8d8910bcf27ec003b/livejson.py#L246-L254
[ "def", "_updateType", "(", "self", ")", ":", "data", "=", "self", ".", "_data", "(", ")", "# Change type if needed", "if", "isinstance", "(", "data", ",", "dict", ")", "and", "isinstance", "(", "self", ",", "ListFile", ")", ":", "self", ".", "__class__",...
91021de60903d2d8b2cfb7d8d8910bcf27ec003b
valid
File.with_data
Initialize a new file that starts out with some data. Pass data as a list, dict, or JSON string.
livejson.py
def with_data(path, data): """Initialize a new file that starts out with some data. Pass data as a list, dict, or JSON string. """ # De-jsonize data if necessary if isinstance(data, str): data = json.loads(data) # Make sure this is really a new file i...
def with_data(path, data): """Initialize a new file that starts out with some data. Pass data as a list, dict, or JSON string. """ # De-jsonize data if necessary if isinstance(data, str): data = json.loads(data) # Make sure this is really a new file i...
[ "Initialize", "a", "new", "file", "that", "starts", "out", "with", "some", "data", ".", "Pass", "data", "as", "a", "list", "dict", "or", "JSON", "string", "." ]
controversial/livejson
python
https://github.com/controversial/livejson/blob/91021de60903d2d8b2cfb7d8d8910bcf27ec003b/livejson.py#L361-L378
[ "def", "with_data", "(", "path", ",", "data", ")", ":", "# De-jsonize data if necessary", "if", "isinstance", "(", "data", ",", "str", ")", ":", "data", "=", "json", ".", "loads", "(", "data", ")", "# Make sure this is really a new file", "if", "os", ".", "p...
91021de60903d2d8b2cfb7d8d8910bcf27ec003b
valid
ZabbixPlugin.is_configured
Check if plugin is configured.
src/sentry_zabbix/plugin.py
def is_configured(self, project, **kwargs): """ Check if plugin is configured. """ params = self.get_option return bool(params('server_host', project) and params('server_port', project))
def is_configured(self, project, **kwargs): """ Check if plugin is configured. """ params = self.get_option return bool(params('server_host', project) and params('server_port', project))
[ "Check", "if", "plugin", "is", "configured", "." ]
m0n5t3r/sentry-zabbix
python
https://github.com/m0n5t3r/sentry-zabbix/blob/3dc6e245b3d67de54e4bd41d2bc9b715fee2dbd2/src/sentry_zabbix/plugin.py#L45-L50
[ "def", "is_configured", "(", "self", ",", "project", ",", "*", "*", "kwargs", ")", ":", "params", "=", "self", ".", "get_option", "return", "bool", "(", "params", "(", "'server_host'", ",", "project", ")", "and", "params", "(", "'server_port'", ",", "pro...
3dc6e245b3d67de54e4bd41d2bc9b715fee2dbd2
valid
ZabbixPlugin.post_process
Process error.
src/sentry_zabbix/plugin.py
def post_process(self, group, event, is_new, is_sample, **kwargs): """ Process error. """ if not self.is_configured(group.project): return host = self.get_option('server_host', group.project) port = int(self.get_option('server_port', group.project)) p...
def post_process(self, group, event, is_new, is_sample, **kwargs): """ Process error. """ if not self.is_configured(group.project): return host = self.get_option('server_host', group.project) port = int(self.get_option('server_port', group.project)) p...
[ "Process", "error", "." ]
m0n5t3r/sentry-zabbix
python
https://github.com/m0n5t3r/sentry-zabbix/blob/3dc6e245b3d67de54e4bd41d2bc9b715fee2dbd2/src/sentry_zabbix/plugin.py#L52-L83
[ "def", "post_process", "(", "self", ",", "group", ",", "event", ",", "is_new", ",", "is_sample", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "is_configured", "(", "group", ".", "project", ")", ":", "return", "host", "=", "self", ".",...
3dc6e245b3d67de54e4bd41d2bc9b715fee2dbd2
valid
PingStats.as_dict
ping statistics. Returns: |dict|: Examples: >>> import pingparsing >>> parser = pingparsing.PingParsing() >>> parser.parse(ping_result) >>> parser.as_dict() { "destination": "google.com", "packet_tr...
pingparsing/_stats.py
def as_dict(self): """ ping statistics. Returns: |dict|: Examples: >>> import pingparsing >>> parser = pingparsing.PingParsing() >>> parser.parse(ping_result) >>> parser.as_dict() { "destination": "...
def as_dict(self): """ ping statistics. Returns: |dict|: Examples: >>> import pingparsing >>> parser = pingparsing.PingParsing() >>> parser.parse(ping_result) >>> parser.as_dict() { "destination": "...
[ "ping", "statistics", "." ]
thombashi/pingparsing
python
https://github.com/thombashi/pingparsing/blob/0249df3e9d8fbd8f6f42243520e5f311736d3be9/pingparsing/_stats.py#L172-L211
[ "def", "as_dict", "(", "self", ")", ":", "return", "{", "\"destination\"", ":", "self", ".", "destination", ",", "\"packet_transmit\"", ":", "self", ".", "packet_transmit", ",", "\"packet_receive\"", ":", "self", ".", "packet_receive", ",", "\"packet_loss_count\""...
0249df3e9d8fbd8f6f42243520e5f311736d3be9
valid
PingStats.as_tuple
ping statistics. Returns: |namedtuple|: Examples: >>> import pingparsing >>> parser = pingparsing.PingParsing() >>> parser.parse(ping_result) >>> parser.as_tuple() PingResult(destination='google.com', packet_transmit=60, packet_re...
pingparsing/_stats.py
def as_tuple(self): """ ping statistics. Returns: |namedtuple|: Examples: >>> import pingparsing >>> parser = pingparsing.PingParsing() >>> parser.parse(ping_result) >>> parser.as_tuple() PingResult(destination='go...
def as_tuple(self): """ ping statistics. Returns: |namedtuple|: Examples: >>> import pingparsing >>> parser = pingparsing.PingParsing() >>> parser.parse(ping_result) >>> parser.as_tuple() PingResult(destination='go...
[ "ping", "statistics", "." ]
thombashi/pingparsing
python
https://github.com/thombashi/pingparsing/blob/0249df3e9d8fbd8f6f42243520e5f311736d3be9/pingparsing/_stats.py#L213-L232
[ "def", "as_tuple", "(", "self", ")", ":", "from", "collections", "import", "namedtuple", "ping_result", "=", "self", ".", "as_dict", "(", ")", "return", "namedtuple", "(", "\"PingStatsTuple\"", ",", "ping_result", ".", "keys", "(", ")", ")", "(", "*", "*",...
0249df3e9d8fbd8f6f42243520e5f311736d3be9
valid
PingTransmitter.ping
Sending ICMP packets. :return: ``ping`` command execution result. :rtype: :py:class:`.PingResult` :raises ValueError: If parameters not valid.
pingparsing/_pingtransmitter.py
def ping(self): """ Sending ICMP packets. :return: ``ping`` command execution result. :rtype: :py:class:`.PingResult` :raises ValueError: If parameters not valid. """ self.__validate_ping_param() ping_proc = subprocrunner.SubprocessRunner(self.__get_pin...
def ping(self): """ Sending ICMP packets. :return: ``ping`` command execution result. :rtype: :py:class:`.PingResult` :raises ValueError: If parameters not valid. """ self.__validate_ping_param() ping_proc = subprocrunner.SubprocessRunner(self.__get_pin...
[ "Sending", "ICMP", "packets", "." ]
thombashi/pingparsing
python
https://github.com/thombashi/pingparsing/blob/0249df3e9d8fbd8f6f42243520e5f311736d3be9/pingparsing/_pingtransmitter.py#L197-L211
[ "def", "ping", "(", "self", ")", ":", "self", ".", "__validate_ping_param", "(", ")", "ping_proc", "=", "subprocrunner", ".", "SubprocessRunner", "(", "self", ".", "__get_ping_command", "(", ")", ")", "ping_proc", ".", "run", "(", ")", "return", "PingResult"...
0249df3e9d8fbd8f6f42243520e5f311736d3be9
valid
PingParsing.parse
Parse ping command output. Args: ping_message (str or :py:class:`~pingparsing.PingResult`): ``ping`` command output. Returns: :py:class:`~pingparsing.PingStats`: Parsed result.
pingparsing/_pingparsing.py
def parse(self, ping_message): """ Parse ping command output. Args: ping_message (str or :py:class:`~pingparsing.PingResult`): ``ping`` command output. Returns: :py:class:`~pingparsing.PingStats`: Parsed result. """ try: ...
def parse(self, ping_message): """ Parse ping command output. Args: ping_message (str or :py:class:`~pingparsing.PingResult`): ``ping`` command output. Returns: :py:class:`~pingparsing.PingStats`: Parsed result. """ try: ...
[ "Parse", "ping", "command", "output", "." ]
thombashi/pingparsing
python
https://github.com/thombashi/pingparsing/blob/0249df3e9d8fbd8f6f42243520e5f311736d3be9/pingparsing/_pingparsing.py#L112-L162
[ "def", "parse", "(", "self", ",", "ping_message", ")", ":", "try", ":", "# accept PingResult instance as an input", "if", "typepy", ".", "is_not_null_string", "(", "ping_message", ".", "stdout", ")", ":", "ping_message", "=", "ping_message", ".", "stdout", "except...
0249df3e9d8fbd8f6f42243520e5f311736d3be9
valid
EmailAddress.send_confirmation
Send a verification email for the email address.
rest_email_auth/models.py
def send_confirmation(self): """ Send a verification email for the email address. """ confirmation = EmailConfirmation.objects.create(email=self) confirmation.send()
def send_confirmation(self): """ Send a verification email for the email address. """ confirmation = EmailConfirmation.objects.create(email=self) confirmation.send()
[ "Send", "a", "verification", "email", "for", "the", "email", "address", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/models.py#L82-L87
[ "def", "send_confirmation", "(", "self", ")", ":", "confirmation", "=", "EmailConfirmation", ".", "objects", ".", "create", "(", "email", "=", "self", ")", "confirmation", ".", "send", "(", ")" ]
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
EmailAddress.send_duplicate_notification
Send a notification about a duplicate signup.
rest_email_auth/models.py
def send_duplicate_notification(self): """ Send a notification about a duplicate signup. """ email_utils.send_email( from_email=settings.DEFAULT_FROM_EMAIL, recipient_list=[self.email], subject=_("Registration Attempt"), template_name="rest...
def send_duplicate_notification(self): """ Send a notification about a duplicate signup. """ email_utils.send_email( from_email=settings.DEFAULT_FROM_EMAIL, recipient_list=[self.email], subject=_("Registration Attempt"), template_name="rest...
[ "Send", "a", "notification", "about", "a", "duplicate", "signup", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/models.py#L89-L100
[ "def", "send_duplicate_notification", "(", "self", ")", ":", "email_utils", ".", "send_email", "(", "from_email", "=", "settings", ".", "DEFAULT_FROM_EMAIL", ",", "recipient_list", "=", "[", "self", ".", "email", "]", ",", "subject", "=", "_", "(", "\"Registra...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
EmailAddress.set_primary
Set this email address as the user's primary email.
rest_email_auth/models.py
def set_primary(self): """ Set this email address as the user's primary email. """ query = EmailAddress.objects.filter(is_primary=True, user=self.user) query = query.exclude(pk=self.pk) # The transaction is atomic so there is never a gap where a user # has no pri...
def set_primary(self): """ Set this email address as the user's primary email. """ query = EmailAddress.objects.filter(is_primary=True, user=self.user) query = query.exclude(pk=self.pk) # The transaction is atomic so there is never a gap where a user # has no pri...
[ "Set", "this", "email", "address", "as", "the", "user", "s", "primary", "email", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/models.py#L102-L121
[ "def", "set_primary", "(", "self", ")", ":", "query", "=", "EmailAddress", ".", "objects", ".", "filter", "(", "is_primary", "=", "True", ",", "user", "=", "self", ".", "user", ")", "query", "=", "query", ".", "exclude", "(", "pk", "=", "self", ".", ...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
EmailConfirmation.confirm
Mark the instance's email as verified.
rest_email_auth/models.py
def confirm(self): """ Mark the instance's email as verified. """ self.email.is_verified = True self.email.save() signals.email_verified.send(email=self.email, sender=self.__class__) logger.info("Verified email address: %s", self.email.email)
def confirm(self): """ Mark the instance's email as verified. """ self.email.is_verified = True self.email.save() signals.email_verified.send(email=self.email, sender=self.__class__) logger.info("Verified email address: %s", self.email.email)
[ "Mark", "the", "instance", "s", "email", "as", "verified", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/models.py#L150-L159
[ "def", "confirm", "(", "self", ")", ":", "self", ".", "email", ".", "is_verified", "=", "True", "self", ".", "email", ".", "save", "(", ")", "signals", ".", "email_verified", ".", "send", "(", "email", "=", "self", ".", "email", ",", "sender", "=", ...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
EmailConfirmation.is_expired
Determine if the confirmation has expired. Returns: bool: ``True`` if the confirmation has expired and ``False`` otherwise.
rest_email_auth/models.py
def is_expired(self): """ Determine if the confirmation has expired. Returns: bool: ``True`` if the confirmation has expired and ``False`` otherwise. """ expiration_time = self.created_at + datetime.timedelta(days=1) return ti...
def is_expired(self): """ Determine if the confirmation has expired. Returns: bool: ``True`` if the confirmation has expired and ``False`` otherwise. """ expiration_time = self.created_at + datetime.timedelta(days=1) return ti...
[ "Determine", "if", "the", "confirmation", "has", "expired", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/models.py#L162-L173
[ "def", "is_expired", "(", "self", ")", ":", "expiration_time", "=", "self", ".", "created_at", "+", "datetime", ".", "timedelta", "(", "days", "=", "1", ")", "return", "timezone", ".", "now", "(", ")", ">", "expiration_time" ]
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
EmailConfirmation.send
Send a verification email to the user.
rest_email_auth/models.py
def send(self): """ Send a verification email to the user. """ context = { "verification_url": app_settings.EMAIL_VERIFICATION_URL.format( key=self.key ) } email_utils.send_email( context=context, from_email...
def send(self): """ Send a verification email to the user. """ context = { "verification_url": app_settings.EMAIL_VERIFICATION_URL.format( key=self.key ) } email_utils.send_email( context=context, from_email...
[ "Send", "a", "verification", "email", "to", "the", "user", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/models.py#L175-L197
[ "def", "send", "(", "self", ")", ":", "context", "=", "{", "\"verification_url\"", ":", "app_settings", ".", "EMAIL_VERIFICATION_URL", ".", "format", "(", "key", "=", "self", ".", "key", ")", "}", "email_utils", ".", "send_email", "(", "context", "=", "con...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
UserFactory._create
Create a new user instance. Args: model_class: The type of model to create an instance of. args: Positional arguments to create the instance with. kwargs: Keyword arguments to create the instance with. Returns: ...
rest_email_auth/factories.py
def _create(cls, model_class, *args, **kwargs): """ Create a new user instance. Args: model_class: The type of model to create an instance of. args: Positional arguments to create the instance with. kwargs: Keyw...
def _create(cls, model_class, *args, **kwargs): """ Create a new user instance. Args: model_class: The type of model to create an instance of. args: Positional arguments to create the instance with. kwargs: Keyw...
[ "Create", "a", "new", "user", "instance", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/factories.py#L59-L77
[ "def", "_create", "(", "cls", ",", "model_class", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "manager", "=", "cls", ".", "_get_manager", "(", "model_class", ")", "return", "manager", ".", "create_user", "(", "*", "args", ",", "*", "*", "kwa...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
EmailSerializer.create
Create a new email and send a confirmation to it. Returns: The newly creating ``EmailAddress`` instance.
rest_email_auth/serializers.py
def create(self, validated_data): """ Create a new email and send a confirmation to it. Returns: The newly creating ``EmailAddress`` instance. """ email_query = models.EmailAddress.objects.filter( email=self.validated_data["email"] ) if e...
def create(self, validated_data): """ Create a new email and send a confirmation to it. Returns: The newly creating ``EmailAddress`` instance. """ email_query = models.EmailAddress.objects.filter( email=self.validated_data["email"] ) if e...
[ "Create", "a", "new", "email", "and", "send", "a", "confirmation", "to", "it", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L36-L63
[ "def", "create", "(", "self", ",", "validated_data", ")", ":", "email_query", "=", "models", ".", "EmailAddress", ".", "objects", ".", "filter", "(", "email", "=", "self", ".", "validated_data", "[", "\"email\"", "]", ")", "if", "email_query", ".", "exists...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
EmailSerializer.update
Update the instance the serializer is bound to. Args: instance: The instance the serializer is bound to. validated_data: The data to update the serializer with. Returns: The updated instance.
rest_email_auth/serializers.py
def update(self, instance, validated_data): """ Update the instance the serializer is bound to. Args: instance: The instance the serializer is bound to. validated_data: The data to update the serializer with. Returns: ...
def update(self, instance, validated_data): """ Update the instance the serializer is bound to. Args: instance: The instance the serializer is bound to. validated_data: The data to update the serializer with. Returns: ...
[ "Update", "the", "instance", "the", "serializer", "is", "bound", "to", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L65-L87
[ "def", "update", "(", "self", ",", "instance", ",", "validated_data", ")", ":", "is_primary", "=", "validated_data", ".", "pop", "(", "\"is_primary\"", ",", "False", ")", "instance", "=", "super", "(", "EmailSerializer", ",", "self", ")", ".", "update", "(...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
EmailSerializer.validate_email
Validate the provided email address. The email address is first modified to match the RFC spec. Namely, the domain portion of the email is lowercased. Returns: The validated email address. Raises: serializers.ValidationError: If the serializer i...
rest_email_auth/serializers.py
def validate_email(self, email): """ Validate the provided email address. The email address is first modified to match the RFC spec. Namely, the domain portion of the email is lowercased. Returns: The validated email address. Raises: serializers...
def validate_email(self, email): """ Validate the provided email address. The email address is first modified to match the RFC spec. Namely, the domain portion of the email is lowercased. Returns: The validated email address. Raises: serializers...
[ "Validate", "the", "provided", "email", "address", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L89-L115
[ "def", "validate_email", "(", "self", ",", "email", ")", ":", "user", ",", "domain", "=", "email", ".", "rsplit", "(", "\"@\"", ",", "1", ")", "email", "=", "\"@\"", ".", "join", "(", "[", "user", ",", "domain", ".", "lower", "(", ")", "]", ")", ...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
EmailSerializer.validate_is_primary
Validate the provided 'is_primary' parameter. Returns: The validated 'is_primary' value. Raises: serializers.ValidationError: If the user attempted to mark an unverified email as their primary email address.
rest_email_auth/serializers.py
def validate_is_primary(self, is_primary): """ Validate the provided 'is_primary' parameter. Returns: The validated 'is_primary' value. Raises: serializers.ValidationError: If the user attempted to mark an unverified email as thei...
def validate_is_primary(self, is_primary): """ Validate the provided 'is_primary' parameter. Returns: The validated 'is_primary' value. Raises: serializers.ValidationError: If the user attempted to mark an unverified email as thei...
[ "Validate", "the", "provided", "is_primary", "parameter", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L117-L139
[ "def", "validate_is_primary", "(", "self", ",", "is_primary", ")", ":", "# TODO: Setting 'is_primary' to 'False' should probably not be", "# allowed.", "if", "is_primary", "and", "not", "(", "self", ".", "instance", "and", "self", ".", "instance", ".", "is_verifie...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
EmailVerificationSerializer.validate
Validate the provided data. Returns: dict: The validated data. Raises: serializers.ValidationError: If the provided password is invalid.
rest_email_auth/serializers.py
def validate(self, data): """ Validate the provided data. Returns: dict: The validated data. Raises: serializers.ValidationError: If the provided password is invalid. """ user = self._confirmation.email.user ...
def validate(self, data): """ Validate the provided data. Returns: dict: The validated data. Raises: serializers.ValidationError: If the provided password is invalid. """ user = self._confirmation.email.user ...
[ "Validate", "the", "provided", "data", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L172-L197
[ "def", "validate", "(", "self", ",", "data", ")", ":", "user", "=", "self", ".", "_confirmation", ".", "email", ".", "user", "if", "(", "app_settings", ".", "EMAIL_VERIFICATION_PASSWORD_REQUIRED", "and", "not", "user", ".", "check_password", "(", "data", "["...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
EmailVerificationSerializer.validate_key
Validate the provided confirmation key. Returns: str: The validated confirmation key. Raises: serializers.ValidationError: If there is no email confirmation with the given key or the confirmation has expired.
rest_email_auth/serializers.py
def validate_key(self, key): """ Validate the provided confirmation key. Returns: str: The validated confirmation key. Raises: serializers.ValidationError: If there is no email confirmation with the given key or th...
def validate_key(self, key): """ Validate the provided confirmation key. Returns: str: The validated confirmation key. Raises: serializers.ValidationError: If there is no email confirmation with the given key or th...
[ "Validate", "the", "provided", "confirmation", "key", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L199-L229
[ "def", "validate_key", "(", "self", ",", "key", ")", ":", "try", ":", "confirmation", "=", "models", ".", "EmailConfirmation", ".", "objects", ".", "select_related", "(", "\"email__user\"", ")", ".", "get", "(", "key", "=", "key", ")", "except", "models", ...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
PasswordResetRequestSerializer.save
Send out a password reset if the provided data is valid. If the provided email address exists and is verified, a reset email is sent to the address. Returns: The password reset token if it was returned and ``None`` otherwise.
rest_email_auth/serializers.py
def save(self): """ Send out a password reset if the provided data is valid. If the provided email address exists and is verified, a reset email is sent to the address. Returns: The password reset token if it was returned and ``None`` otherwise. ...
def save(self): """ Send out a password reset if the provided data is valid. If the provided email address exists and is verified, a reset email is sent to the address. Returns: The password reset token if it was returned and ``None`` otherwise. ...
[ "Send", "out", "a", "password", "reset", "if", "the", "provided", "data", "is", "valid", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L241-L262
[ "def", "save", "(", "self", ")", ":", "try", ":", "email", "=", "models", ".", "EmailAddress", ".", "objects", ".", "get", "(", "email", "=", "self", ".", "validated_data", "[", "\"email\"", "]", ",", "is_verified", "=", "True", ")", "except", "models"...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
PasswordResetSerializer.save
Reset the user's password if the provided information is valid.
rest_email_auth/serializers.py
def save(self): """ Reset the user's password if the provided information is valid. """ token = models.PasswordResetToken.objects.get( key=self.validated_data["key"] ) token.email.user.set_password(self.validated_data["password"]) token.email.user.sav...
def save(self): """ Reset the user's password if the provided information is valid. """ token = models.PasswordResetToken.objects.get( key=self.validated_data["key"] ) token.email.user.set_password(self.validated_data["password"]) token.email.user.sav...
[ "Reset", "the", "user", "s", "password", "if", "the", "provided", "information", "is", "valid", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L282-L295
[ "def", "save", "(", "self", ")", ":", "token", "=", "models", ".", "PasswordResetToken", ".", "objects", ".", "get", "(", "key", "=", "self", ".", "validated_data", "[", "\"key\"", "]", ")", "token", ".", "email", ".", "user", ".", "set_password", "(",...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
PasswordResetSerializer.validate_key
Validate the provided reset key. Returns: The validated key. Raises: serializers.ValidationError: If the provided key does not exist.
rest_email_auth/serializers.py
def validate_key(self, key): """ Validate the provided reset key. Returns: The validated key. Raises: serializers.ValidationError: If the provided key does not exist. """ if not models.PasswordResetToken.valid_tokens.filter(key=ke...
def validate_key(self, key): """ Validate the provided reset key. Returns: The validated key. Raises: serializers.ValidationError: If the provided key does not exist. """ if not models.PasswordResetToken.valid_tokens.filter(key=ke...
[ "Validate", "the", "provided", "reset", "key", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L297-L313
[ "def", "validate_key", "(", "self", ",", "key", ")", ":", "if", "not", "models", ".", "PasswordResetToken", ".", "valid_tokens", ".", "filter", "(", "key", "=", "key", ")", ".", "exists", "(", ")", ":", "raise", "serializers", ".", "ValidationError", "("...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
RegistrationSerializer.create
Create a new user from the data passed to the serializer. If the provided email has not been verified yet, the user is created and a verification email is sent to the address. Otherwise we send a notification to the email address that someone attempted to register with an email that's a...
rest_email_auth/serializers.py
def create(self, validated_data): """ Create a new user from the data passed to the serializer. If the provided email has not been verified yet, the user is created and a verification email is sent to the address. Otherwise we send a notification to the email address that ...
def create(self, validated_data): """ Create a new user from the data passed to the serializer. If the provided email has not been verified yet, the user is created and a verification email is sent to the address. Otherwise we send a notification to the email address that ...
[ "Create", "a", "new", "user", "from", "the", "data", "passed", "to", "the", "serializer", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L350-L395
[ "def", "create", "(", "self", ",", "validated_data", ")", ":", "email", "=", "validated_data", ".", "pop", "(", "\"email\"", ")", "password", "=", "validated_data", ".", "pop", "(", "\"password\"", ")", "# We don't save the user instance yet in case the provided email...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
RegistrationSerializer.validate_email
Validate the provided email address. Args: email: The email address to validate. Returns: The provided email address, transformed to match the RFC spec. Namely, the domain portion of the email must be lowercase.
rest_email_auth/serializers.py
def validate_email(self, email): """ Validate the provided email address. Args: email: The email address to validate. Returns: The provided email address, transformed to match the RFC spec. Namely, the domain portion of the email must...
def validate_email(self, email): """ Validate the provided email address. Args: email: The email address to validate. Returns: The provided email address, transformed to match the RFC spec. Namely, the domain portion of the email must...
[ "Validate", "the", "provided", "email", "address", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L397-L412
[ "def", "validate_email", "(", "self", ",", "email", ")", ":", "user", ",", "domain", "=", "email", ".", "rsplit", "(", "\"@\"", ",", "1", ")", "return", "\"@\"", ".", "join", "(", "[", "user", ",", "domain", ".", "lower", "(", ")", "]", ")" ]
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
ResendVerificationSerializer.save
Resend a verification email to the provided address. If the provided email is already verified no action is taken.
rest_email_auth/serializers.py
def save(self): """ Resend a verification email to the provided address. If the provided email is already verified no action is taken. """ try: email = models.EmailAddress.objects.get( email=self.validated_data["email"], is_verified=False ...
def save(self): """ Resend a verification email to the provided address. If the provided email is already verified no action is taken. """ try: email = models.EmailAddress.objects.get( email=self.validated_data["email"], is_verified=False ...
[ "Resend", "a", "verification", "email", "to", "the", "provided", "address", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/serializers.py#L443-L465
[ "def", "save", "(", "self", ")", ":", "try", ":", "email", "=", "models", ".", "EmailAddress", ".", "objects", ".", "get", "(", "email", "=", "self", ".", "validated_data", "[", "\"email\"", "]", ",", "is_verified", "=", "False", ")", "logger", ".", ...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
EmailAddressManager.create
Create a new email address.
rest_email_auth/managers.py
def create(self, *args, **kwargs): """ Create a new email address. """ is_primary = kwargs.pop("is_primary", False) with transaction.atomic(): email = super(EmailAddressManager, self).create(*args, **kwargs) if is_primary: email.set_prima...
def create(self, *args, **kwargs): """ Create a new email address. """ is_primary = kwargs.pop("is_primary", False) with transaction.atomic(): email = super(EmailAddressManager, self).create(*args, **kwargs) if is_primary: email.set_prima...
[ "Create", "a", "new", "email", "address", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/managers.py#L12-L24
[ "def", "create", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "is_primary", "=", "kwargs", ".", "pop", "(", "\"is_primary\"", ",", "False", ")", "with", "transaction", ".", "atomic", "(", ")", ":", "email", "=", "super", "(", "...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
ValidPasswordResetTokenManager.get_queryset
Return all unexpired password reset tokens.
rest_email_auth/managers.py
def get_queryset(self): """ Return all unexpired password reset tokens. """ oldest = timezone.now() - app_settings.PASSWORD_RESET_EXPIRATION queryset = super(ValidPasswordResetTokenManager, self).get_queryset() return queryset.filter(created_at__gt=oldest)
def get_queryset(self): """ Return all unexpired password reset tokens. """ oldest = timezone.now() - app_settings.PASSWORD_RESET_EXPIRATION queryset = super(ValidPasswordResetTokenManager, self).get_queryset() return queryset.filter(created_at__gt=oldest)
[ "Return", "all", "unexpired", "password", "reset", "tokens", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/managers.py#L34-L41
[ "def", "get_queryset", "(", "self", ")", ":", "oldest", "=", "timezone", ".", "now", "(", ")", "-", "app_settings", ".", "PASSWORD_RESET_EXPIRATION", "queryset", "=", "super", "(", "ValidPasswordResetTokenManager", ",", "self", ")", ".", "get_queryset", "(", "...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
Command.handle
Handle execution of the command.
rest_email_auth/management/commands/cleanemailconfirmations.py
def handle(self, *args, **kwargs): """ Handle execution of the command. """ cutoff = timezone.now() cutoff -= app_settings.CONFIRMATION_EXPIRATION cutoff -= app_settings.CONFIRMATION_SAVE_PERIOD queryset = models.EmailConfirmation.objects.filter( crea...
def handle(self, *args, **kwargs): """ Handle execution of the command. """ cutoff = timezone.now() cutoff -= app_settings.CONFIRMATION_EXPIRATION cutoff -= app_settings.CONFIRMATION_SAVE_PERIOD queryset = models.EmailConfirmation.objects.filter( crea...
[ "Handle", "execution", "of", "the", "command", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/management/commands/cleanemailconfirmations.py#L14-L39
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cutoff", "=", "timezone", ".", "now", "(", ")", "cutoff", "-=", "app_settings", ".", "CONFIRMATION_EXPIRATION", "cutoff", "-=", "app_settings", ".", "CONFIRMATION_SAVE_PERIOD...
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
BaseBackend.get_user
Get a user by their ID. Args: user_id: The ID of the user to fetch. Returns: The user with the specified ID if they exist and ``None`` otherwise.
rest_email_auth/authentication.py
def get_user(self, user_id): """ Get a user by their ID. Args: user_id: The ID of the user to fetch. Returns: The user with the specified ID if they exist and ``None`` otherwise. """ try: return get_user_mo...
def get_user(self, user_id): """ Get a user by their ID. Args: user_id: The ID of the user to fetch. Returns: The user with the specified ID if they exist and ``None`` otherwise. """ try: return get_user_mo...
[ "Get", "a", "user", "by", "their", "ID", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/authentication.py#L16-L31
[ "def", "get_user", "(", "self", ",", "user_id", ")", ":", "try", ":", "return", "get_user_model", "(", ")", ".", "objects", ".", "get", "(", "id", "=", "user_id", ")", "except", "get_user_model", "(", ")", ".", "DoesNotExist", ":", "return", "None" ]
7e752c4d77ae02d2d046f214f56e743aa12ab23f
valid
VerifiedEmailBackend.authenticate
Attempt to authenticate a set of credentials. Args: request: The request associated with the authentication attempt. email: The user's email address. password: The user's password. username: An alias...
rest_email_auth/authentication.py
def authenticate(self, request, email=None, password=None, username=None): """ Attempt to authenticate a set of credentials. Args: request: The request associated with the authentication attempt. email: The user's email address. ...
def authenticate(self, request, email=None, password=None, username=None): """ Attempt to authenticate a set of credentials. Args: request: The request associated with the authentication attempt. email: The user's email address. ...
[ "Attempt", "to", "authenticate", "a", "set", "of", "credentials", "." ]
cdriehuys/django-rest-email-auth
python
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/authentication.py#L40-L74
[ "def", "authenticate", "(", "self", ",", "request", ",", "email", "=", "None", ",", "password", "=", "None", ",", "username", "=", "None", ")", ":", "email", "=", "email", "or", "username", "try", ":", "email_instance", "=", "models", ".", "EmailAddress"...
7e752c4d77ae02d2d046f214f56e743aa12ab23f