repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_login_page
def _get_login_page(self): """Go to the login page.""" try: raw_res = yield from self._session.get(HOME_URL, timeout=self._timeout) except OSError: raise PyHydroQuebecError("Can not connect to login page") # Get l...
python
def _get_login_page(self): """Go to the login page.""" try: raw_res = yield from self._session.get(HOME_URL, timeout=self._timeout) except OSError: raise PyHydroQuebecError("Can not connect to login page") # Get l...
[ "def", "_get_login_page", "(", "self", ")", ":", "try", ":", "raw_res", "=", "yield", "from", "self", ".", "_session", ".", "get", "(", "HOME_URL", ",", "timeout", "=", "self", ".", "_timeout", ")", "except", "OSError", ":", "raise", "PyHydroQuebecError", ...
Go to the login page.
[ "Go", "to", "the", "login", "page", "." ]
train
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L73-L89
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._post_login_page
def _post_login_page(self, login_url): """Login to HydroQuebec website.""" data = {"login": self.username, "_58_password": self.password} try: raw_res = yield from self._session.post(login_url, data=data, ...
python
def _post_login_page(self, login_url): """Login to HydroQuebec website.""" data = {"login": self.username, "_58_password": self.password} try: raw_res = yield from self._session.post(login_url, data=data, ...
[ "def", "_post_login_page", "(", "self", ",", "login_url", ")", ":", "data", "=", "{", "\"login\"", ":", "self", ".", "username", ",", "\"_58_password\"", ":", "self", ".", "password", "}", "try", ":", "raw_res", "=", "yield", "from", "self", ".", "_sessi...
Login to HydroQuebec website.
[ "Login", "to", "HydroQuebec", "website", "." ]
train
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L92-L107
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_p_p_id_and_contract
def _get_p_p_id_and_contract(self): """Get id of consumption profile.""" contracts = {} try: raw_res = yield from self._session.get(PROFILE_URL, timeout=self._timeout) except OSError: raise PyHydroQuebecError("Can...
python
def _get_p_p_id_and_contract(self): """Get id of consumption profile.""" contracts = {} try: raw_res = yield from self._session.get(PROFILE_URL, timeout=self._timeout) except OSError: raise PyHydroQuebecError("Can...
[ "def", "_get_p_p_id_and_contract", "(", "self", ")", ":", "contracts", "=", "{", "}", "try", ":", "raw_res", "=", "yield", "from", "self", ".", "_session", ".", "get", "(", "PROFILE_URL", ",", "timeout", "=", "self", ".", "_timeout", ")", "except", "OSEr...
Get id of consumption profile.
[ "Get", "id", "of", "consumption", "profile", "." ]
train
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L110-L142
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_lonely_contract
def _get_lonely_contract(self): """Get contract number when we have only one contract.""" contracts = {} try: raw_res = yield from self._session.get(MAIN_URL, timeout=self._timeout) except OSError: raise PyHydroQu...
python
def _get_lonely_contract(self): """Get contract number when we have only one contract.""" contracts = {} try: raw_res = yield from self._session.get(MAIN_URL, timeout=self._timeout) except OSError: raise PyHydroQu...
[ "def", "_get_lonely_contract", "(", "self", ")", ":", "contracts", "=", "{", "}", "try", ":", "raw_res", "=", "yield", "from", "self", ".", "_session", ".", "get", "(", "MAIN_URL", ",", "timeout", "=", "self", ".", "_timeout", ")", "except", "OSError", ...
Get contract number when we have only one contract.
[ "Get", "contract", "number", "when", "we", "have", "only", "one", "contract", "." ]
train
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L145-L166
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_balances
def _get_balances(self): """Get all balances. .. todo:: IT SEEMS balances are shown (MAIN_URL) in the same order that contracts in profile page (PROFILE_URL). Maybe we should ensure that. """ balances = [] try: raw_res = yield fro...
python
def _get_balances(self): """Get all balances. .. todo:: IT SEEMS balances are shown (MAIN_URL) in the same order that contracts in profile page (PROFILE_URL). Maybe we should ensure that. """ balances = [] try: raw_res = yield fro...
[ "def", "_get_balances", "(", "self", ")", ":", "balances", "=", "[", "]", "try", ":", "raw_res", "=", "yield", "from", "self", ".", "_session", ".", "get", "(", "MAIN_URL", ",", "timeout", "=", "self", ".", "_timeout", ")", "except", "OSError", ":", ...
Get all balances. .. todo:: IT SEEMS balances are shown (MAIN_URL) in the same order that contracts in profile page (PROFILE_URL). Maybe we should ensure that.
[ "Get", "all", "balances", "." ]
train
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L169-L199
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._load_contract_page
def _load_contract_page(self, contract_url): """Load the profile page of a specific contract when we have multiple contracts.""" try: yield from self._session.get(contract_url, timeout=self._timeout) except OSError: raise PyHydroQu...
python
def _load_contract_page(self, contract_url): """Load the profile page of a specific contract when we have multiple contracts.""" try: yield from self._session.get(contract_url, timeout=self._timeout) except OSError: raise PyHydroQu...
[ "def", "_load_contract_page", "(", "self", ",", "contract_url", ")", ":", "try", ":", "yield", "from", "self", ".", "_session", ".", "get", "(", "contract_url", ",", "timeout", "=", "self", ".", "_timeout", ")", "except", "OSError", ":", "raise", "PyHydroQ...
Load the profile page of a specific contract when we have multiple contracts.
[ "Load", "the", "profile", "page", "of", "a", "specific", "contract", "when", "we", "have", "multiple", "contracts", "." ]
train
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L202-L209
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_annual_data
def _get_annual_data(self, p_p_id): """Get annual data.""" params = {"p_p_id": p_p_id, "p_p_lifecycle": 2, "p_p_state": "normal", "p_p_mode": "view", "p_p_resource_id": "resourceObtenirDonneesConsommationAnnuelles"} try: ...
python
def _get_annual_data(self, p_p_id): """Get annual data.""" params = {"p_p_id": p_p_id, "p_p_lifecycle": 2, "p_p_state": "normal", "p_p_mode": "view", "p_p_resource_id": "resourceObtenirDonneesConsommationAnnuelles"} try: ...
[ "def", "_get_annual_data", "(", "self", ",", "p_p_id", ")", ":", "params", "=", "{", "\"p_p_id\"", ":", "p_p_id", ",", "\"p_p_lifecycle\"", ":", "2", ",", "\"p_p_state\"", ":", "\"normal\"", ",", "\"p_p_mode\"", ":", "\"view\"", ",", "\"p_p_resource_id\"", ":"...
Get annual data.
[ "Get", "annual", "data", "." ]
train
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L212-L239
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_monthly_data
def _get_monthly_data(self, p_p_id): """Get monthly data.""" params = {"p_p_id": p_p_id, "p_p_lifecycle": 2, "p_p_resource_id": ("resourceObtenirDonnees" "PeriodesConsommation")} try: raw_res = yield from self....
python
def _get_monthly_data(self, p_p_id): """Get monthly data.""" params = {"p_p_id": p_p_id, "p_p_lifecycle": 2, "p_p_resource_id": ("resourceObtenirDonnees" "PeriodesConsommation")} try: raw_res = yield from self....
[ "def", "_get_monthly_data", "(", "self", ",", "p_p_id", ")", ":", "params", "=", "{", "\"p_p_id\"", ":", "p_p_id", ",", "\"p_p_lifecycle\"", ":", "2", ",", "\"p_p_resource_id\"", ":", "(", "\"resourceObtenirDonnees\"", "\"PeriodesConsommation\"", ")", "}", "try", ...
Get monthly data.
[ "Get", "monthly", "data", "." ]
train
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L242-L262
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient._get_hourly_data
def _get_hourly_data(self, day_date, p_p_id): """Get Hourly Data.""" params = {"p_p_id": p_p_id, "p_p_lifecycle": 2, "p_p_state": "normal", "p_p_mode": "view", "p_p_resource_id": "resourceObtenirDonneesConsommationHoraires", ...
python
def _get_hourly_data(self, day_date, p_p_id): """Get Hourly Data.""" params = {"p_p_id": p_p_id, "p_p_lifecycle": 2, "p_p_state": "normal", "p_p_mode": "view", "p_p_resource_id": "resourceObtenirDonneesConsommationHoraires", ...
[ "def", "_get_hourly_data", "(", "self", ",", "day_date", ",", "p_p_id", ")", ":", "params", "=", "{", "\"p_p_id\"", ":", "p_p_id", ",", "\"p_p_lifecycle\"", ":", "2", ",", "\"p_p_state\"", ":", "\"normal\"", ",", "\"p_p_mode\"", ":", "\"view\"", ",", "\"p_p_...
Get Hourly Data.
[ "Get", "Hourly", "Data", "." ]
train
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L290-L355
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient.fetch_data_detailled_energy_use
def fetch_data_detailled_energy_use(self, start_date=None, end_date=None): """Get detailled energy use from a specific contract.""" if start_date is None: start_date = datetime.datetime.now(HQ_TIMEZONE) - datetime.timedelta(days=1) if end_date is None: end_date = datetime...
python
def fetch_data_detailled_energy_use(self, start_date=None, end_date=None): """Get detailled energy use from a specific contract.""" if start_date is None: start_date = datetime.datetime.now(HQ_TIMEZONE) - datetime.timedelta(days=1) if end_date is None: end_date = datetime...
[ "def", "fetch_data_detailled_energy_use", "(", "self", ",", "start_date", "=", "None", ",", "end_date", "=", "None", ")", ":", "if", "start_date", "is", "None", ":", "start_date", "=", "datetime", ".", "datetime", ".", "now", "(", "HQ_TIMEZONE", ")", "-", ...
Get detailled energy use from a specific contract.
[ "Get", "detailled", "energy", "use", "from", "a", "specific", "contract", "." ]
train
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L358-L392
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient.fetch_data
def fetch_data(self): """Get the latest data from HydroQuebec.""" # Get http session yield from self._get_httpsession() # Get login page login_url = yield from self._get_login_page() # Post login page yield from self._post_login_page(login_url) # Get p_p_i...
python
def fetch_data(self): """Get the latest data from HydroQuebec.""" # Get http session yield from self._get_httpsession() # Get login page login_url = yield from self._get_login_page() # Post login page yield from self._post_login_page(login_url) # Get p_p_i...
[ "def", "fetch_data", "(", "self", ")", ":", "# Get http session", "yield", "from", "self", ".", "_get_httpsession", "(", ")", "# Get login page", "login_url", "=", "yield", "from", "self", ".", "_get_login_page", "(", ")", "# Post login page", "yield", "from", "...
Get the latest data from HydroQuebec.
[ "Get", "the", "latest", "data", "from", "HydroQuebec", "." ]
train
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L395-L468
titilambert/pyhydroquebec
pyhydroquebec/client.py
HydroQuebecClient.get_data
def get_data(self, contract=None): """Return collected data.""" if contract is None: return self._data if contract in self._data.keys(): return {contract: self._data[contract]} raise PyHydroQuebecError("Contract {} not found".format(contract))
python
def get_data(self, contract=None): """Return collected data.""" if contract is None: return self._data if contract in self._data.keys(): return {contract: self._data[contract]} raise PyHydroQuebecError("Contract {} not found".format(contract))
[ "def", "get_data", "(", "self", ",", "contract", "=", "None", ")", ":", "if", "contract", "is", "None", ":", "return", "self", ".", "_data", "if", "contract", "in", "self", ".", "_data", ".", "keys", "(", ")", ":", "return", "{", "contract", ":", "...
Return collected data.
[ "Return", "collected", "data", "." ]
train
https://github.com/titilambert/pyhydroquebec/blob/4ea1374a63944413889c147d91961eda0605d4fd/pyhydroquebec/client.py#L470-L476
3ll3d00d/vibe
backend/src/recorder/common/heartbeater.py
Heartbeater.ping
def ping(self): """ Posts the current state of each device to the server and schedules the next call in n seconds. :param serverURL: :return: """ from datetime import datetime nextRun = datetime.utcnow().timestamp() + self.cfg.getPingInterval() self.sendHe...
python
def ping(self): """ Posts the current state of each device to the server and schedules the next call in n seconds. :param serverURL: :return: """ from datetime import datetime nextRun = datetime.utcnow().timestamp() + self.cfg.getPingInterval() self.sendHe...
[ "def", "ping", "(", "self", ")", ":", "from", "datetime", "import", "datetime", "nextRun", "=", "datetime", ".", "utcnow", "(", ")", ".", "timestamp", "(", ")", "+", "self", ".", "cfg", ".", "getPingInterval", "(", ")", "self", ".", "sendHeartbeat", "(...
Posts the current state of each device to the server and schedules the next call in n seconds. :param serverURL: :return:
[ "Posts", "the", "current", "state", "of", "each", "device", "to", "the", "server", "and", "schedules", "the", "next", "call", "in", "n", "seconds", ".", ":", "param", "serverURL", ":", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/heartbeater.py#L16-L25
3ll3d00d/vibe
backend/src/recorder/common/heartbeater.py
Heartbeater.sendHeartbeat
def sendHeartbeat(self): """ Posts the current state to the server. :param serverURL: the URL to ping. :return: """ for name, md in self.cfg.recordingDevices.items(): try: data = marshal(md, recordingDeviceFields) data['serviceU...
python
def sendHeartbeat(self): """ Posts the current state to the server. :param serverURL: the URL to ping. :return: """ for name, md in self.cfg.recordingDevices.items(): try: data = marshal(md, recordingDeviceFields) data['serviceU...
[ "def", "sendHeartbeat", "(", "self", ")", ":", "for", "name", ",", "md", "in", "self", ".", "cfg", ".", "recordingDevices", ".", "items", "(", ")", ":", "try", ":", "data", "=", "marshal", "(", "md", ",", "recordingDeviceFields", ")", "data", "[", "'...
Posts the current state to the server. :param serverURL: the URL to ping. :return:
[ "Posts", "the", "current", "state", "to", "the", "server", ".", ":", "param", "serverURL", ":", "the", "URL", "to", "ping", ".", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/heartbeater.py#L27-L46
3ll3d00d/vibe
backend/src/recorder/common/heartbeater.py
Heartbeater.scheduleNextHeartbeat
def scheduleNextHeartbeat(self, nextRun): """ Schedules the next ping. :param nextRun: when we should run next. :param serverURL: the URL to ping. :return: """ import threading from datetime import datetime tilNextTime = max(nextRun - datetime.utcn...
python
def scheduleNextHeartbeat(self, nextRun): """ Schedules the next ping. :param nextRun: when we should run next. :param serverURL: the URL to ping. :return: """ import threading from datetime import datetime tilNextTime = max(nextRun - datetime.utcn...
[ "def", "scheduleNextHeartbeat", "(", "self", ",", "nextRun", ")", ":", "import", "threading", "from", "datetime", "import", "datetime", "tilNextTime", "=", "max", "(", "nextRun", "-", "datetime", ".", "utcnow", "(", ")", ".", "timestamp", "(", ")", ",", "0...
Schedules the next ping. :param nextRun: when we should run next. :param serverURL: the URL to ping. :return:
[ "Schedules", "the", "next", "ping", ".", ":", "param", "nextRun", ":", "when", "we", "should", "run", "next", ".", ":", "param", "serverURL", ":", "the", "URL", "to", "ping", ".", ":", "return", ":" ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/recorder/common/heartbeater.py#L48-L59
Xion/callee
callee/collections.py
CollectionMatcher._validate_argument
def _validate_argument(self, arg): """Validate a type or matcher argument to the constructor.""" if arg is None: return arg if isinstance(arg, type): return InstanceOf(arg) if not isinstance(arg, BaseMatcher): raise TypeError( "argumen...
python
def _validate_argument(self, arg): """Validate a type or matcher argument to the constructor.""" if arg is None: return arg if isinstance(arg, type): return InstanceOf(arg) if not isinstance(arg, BaseMatcher): raise TypeError( "argumen...
[ "def", "_validate_argument", "(", "self", ",", "arg", ")", ":", "if", "arg", "is", "None", ":", "return", "arg", "if", "isinstance", "(", "arg", ",", "type", ")", ":", "return", "InstanceOf", "(", "arg", ")", "if", "not", "isinstance", "(", "arg", ",...
Validate a type or matcher argument to the constructor.
[ "Validate", "a", "type", "or", "matcher", "argument", "to", "the", "constructor", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/collections.py#L38-L50
Xion/callee
callee/collections.py
MappingMatcher._initialize
def _initialize(self, *args, **kwargs): """Initiaize the mapping matcher with constructor arguments.""" self.items = None self.keys = None self.values = None if args: if len(args) != 2: raise TypeError("expected exactly two positional arguments, " ...
python
def _initialize(self, *args, **kwargs): """Initiaize the mapping matcher with constructor arguments.""" self.items = None self.keys = None self.values = None if args: if len(args) != 2: raise TypeError("expected exactly two positional arguments, " ...
[ "def", "_initialize", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "items", "=", "None", "self", ".", "keys", "=", "None", "self", ".", "values", "=", "None", "if", "args", ":", "if", "len", "(", "args", ")", "...
Initiaize the mapping matcher with constructor arguments.
[ "Initiaize", "the", "mapping", "matcher", "with", "constructor", "arguments", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/collections.py#L163-L208
Xion/callee
tasks.py
docs
def docs(ctx, output='html', rebuild=False, show=True, verbose=True): """Build the docs and show them in default web browser.""" sphinx_build = ctx.run( 'sphinx-build -b {output} {all} {verbose} docs docs/_build'.format( output=output, all='-a -E' if rebuild else '', ...
python
def docs(ctx, output='html', rebuild=False, show=True, verbose=True): """Build the docs and show them in default web browser.""" sphinx_build = ctx.run( 'sphinx-build -b {output} {all} {verbose} docs docs/_build'.format( output=output, all='-a -E' if rebuild else '', ...
[ "def", "docs", "(", "ctx", ",", "output", "=", "'html'", ",", "rebuild", "=", "False", ",", "show", "=", "True", ",", "verbose", "=", "True", ")", ":", "sphinx_build", "=", "ctx", ".", "run", "(", "'sphinx-build -b {output} {all} {verbose} docs docs/_build'", ...
Build the docs and show them in default web browser.
[ "Build", "the", "docs", "and", "show", "them", "in", "default", "web", "browser", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/tasks.py#L47-L61
Xion/callee
tasks.py
upload
def upload(ctx, yes=False): """Upload the package to PyPI.""" import callee version = callee.__version__ # check the packages version # TODO: add a 'release' to automatically bless a version as release one if version.endswith('-dev'): fatal("Can't upload a development version (%s) to Py...
python
def upload(ctx, yes=False): """Upload the package to PyPI.""" import callee version = callee.__version__ # check the packages version # TODO: add a 'release' to automatically bless a version as release one if version.endswith('-dev'): fatal("Can't upload a development version (%s) to Py...
[ "def", "upload", "(", "ctx", ",", "yes", "=", "False", ")", ":", "import", "callee", "version", "=", "callee", ".", "__version__", "# check the packages version", "# TODO: add a 'release' to automatically bless a version as release one", "if", "version", ".", "endswith", ...
Upload the package to PyPI.
[ "Upload", "the", "package", "to", "PyPI", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/tasks.py#L69-L101
Xion/callee
tasks.py
fatal
def fatal(*args, **kwargs): """Log an error message and exit. Following arguments are keyword-only. :param exitcode: Optional exit code to use :param cause: Optional Invoke's Result object, i.e. result of a subprocess invocation """ # determine the exitcode to return to the o...
python
def fatal(*args, **kwargs): """Log an error message and exit. Following arguments are keyword-only. :param exitcode: Optional exit code to use :param cause: Optional Invoke's Result object, i.e. result of a subprocess invocation """ # determine the exitcode to return to the o...
[ "def", "fatal", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# determine the exitcode to return to the operating system", "exitcode", "=", "None", "if", "'exitcode'", "in", "kwargs", ":", "exitcode", "=", "kwargs", ".", "pop", "(", "'exitcode'", ")", ...
Log an error message and exit. Following arguments are keyword-only. :param exitcode: Optional exit code to use :param cause: Optional Invoke's Result object, i.e. result of a subprocess invocation
[ "Log", "an", "error", "message", "and", "exit", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/tasks.py#L106-L128
scivision/msise00
archive/f2py.py
rungtd1d
def rungtd1d(time: Union[datetime, str, np.ndarray], altkm: np.ndarray, glat: float, glon: float) -> xarray.Dataset: """ This is the "atomic" function looped by other functions """ time = todt64(time) # %% get solar parameters for date f107Ap = gi.getApF107(time, smooth...
python
def rungtd1d(time: Union[datetime, str, np.ndarray], altkm: np.ndarray, glat: float, glon: float) -> xarray.Dataset: """ This is the "atomic" function looped by other functions """ time = todt64(time) # %% get solar parameters for date f107Ap = gi.getApF107(time, smooth...
[ "def", "rungtd1d", "(", "time", ":", "Union", "[", "datetime", ",", "str", ",", "np", ".", "ndarray", "]", ",", "altkm", ":", "np", ".", "ndarray", ",", "glat", ":", "float", ",", "glon", ":", "float", ")", "->", "xarray", ".", "Dataset", ":", "t...
This is the "atomic" function looped by other functions
[ "This", "is", "the", "atomic", "function", "looped", "by", "other", "functions" ]
train
https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/archive/f2py.py#L3-L51
WoLpH/mailjet
mailjet/contrib/django_mailjet/views.py
SubscriptionView.form_valid
def form_valid(self, form): """ Call `form.save()` and super itself. """ form.save() return super(SubscriptionView, self).form_valid(form)
python
def form_valid(self, form): """ Call `form.save()` and super itself. """ form.save() return super(SubscriptionView, self).form_valid(form)
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "form", ".", "save", "(", ")", "return", "super", "(", "SubscriptionView", ",", "self", ")", ".", "form_valid", "(", "form", ")" ]
Call `form.save()` and super itself.
[ "Call", "form", ".", "save", "()", "and", "super", "itself", "." ]
train
https://github.com/WoLpH/mailjet/blob/f7f5102bf52be6a4a9c62afe474387481c806e27/mailjet/contrib/django_mailjet/views.py#L13-L16
anthok/overwatch-api
overwatch_api/core.py
AsyncOWAPI._uses_aiohttp_session
def _uses_aiohttp_session(func): """This is a decorator that creates an async with statement around a function, and makes sure that a _session argument is always passed. Only usable on async functions of course. The _session argument is (supposed to be) an aiohttp.ClientSession instance in all f...
python
def _uses_aiohttp_session(func): """This is a decorator that creates an async with statement around a function, and makes sure that a _session argument is always passed. Only usable on async functions of course. The _session argument is (supposed to be) an aiohttp.ClientSession instance in all f...
[ "def", "_uses_aiohttp_session", "(", "func", ")", ":", "# The function the decorator returns", "async", "def", "decorated_func", "(", "*", "args", ",", "session", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "session", "is", "not", "None", ":", "# T...
This is a decorator that creates an async with statement around a function, and makes sure that a _session argument is always passed. Only usable on async functions of course. The _session argument is (supposed to be) an aiohttp.ClientSession instance in all functions that this decorator has been used o...
[ "This", "is", "a", "decorator", "that", "creates", "an", "async", "with", "statement", "around", "a", "function", "and", "makes", "sure", "that", "a", "_session", "argument", "is", "always", "passed", ".", "Only", "usable", "on", "async", "functions", "of", ...
train
https://github.com/anthok/overwatch-api/blob/aba976a3c07c4932de13f4236d924b2901b149b9/overwatch_api/core.py#L46-L64
anthok/overwatch-api
overwatch_api/core.py
AsyncOWAPI._add_request_parameters
def _add_request_parameters(func): """Adds the ratelimit and request timeout parameters to a function.""" # The function the decorator returns async def decorated_func(*args, handle_ratelimit=None, max_tries=None, request_timeout=None, **kwargs): return await func(*args, handle_rate...
python
def _add_request_parameters(func): """Adds the ratelimit and request timeout parameters to a function.""" # The function the decorator returns async def decorated_func(*args, handle_ratelimit=None, max_tries=None, request_timeout=None, **kwargs): return await func(*args, handle_rate...
[ "def", "_add_request_parameters", "(", "func", ")", ":", "# The function the decorator returns", "async", "def", "decorated_func", "(", "*", "args", ",", "handle_ratelimit", "=", "None", ",", "max_tries", "=", "None", ",", "request_timeout", "=", "None", ",", "*",...
Adds the ratelimit and request timeout parameters to a function.
[ "Adds", "the", "ratelimit", "and", "request", "timeout", "parameters", "to", "a", "function", "." ]
train
https://github.com/anthok/overwatch-api/blob/aba976a3c07c4932de13f4236d924b2901b149b9/overwatch_api/core.py#L66-L75
anthok/overwatch-api
overwatch_api/core.py
AsyncOWAPI.get_stats
async def get_stats(self, battletag: str, regions=(EUROPE, KOREA, AMERICAS, CHINA, JAPAN, ANY), platform=None, _session=None, handle_ratelimit=None, max_tries=None, request_timeout=None): """Returns the stats for the profiles on the specified regions and platform. The format for regions ...
python
async def get_stats(self, battletag: str, regions=(EUROPE, KOREA, AMERICAS, CHINA, JAPAN, ANY), platform=None, _session=None, handle_ratelimit=None, max_tries=None, request_timeout=None): """Returns the stats for the profiles on the specified regions and platform. The format for regions ...
[ "async", "def", "get_stats", "(", "self", ",", "battletag", ":", "str", ",", "regions", "=", "(", "EUROPE", ",", "KOREA", ",", "AMERICAS", ",", "CHINA", ",", "JAPAN", ",", "ANY", ")", ",", "platform", "=", "None", ",", "_session", "=", "None", ",", ...
Returns the stats for the profiles on the specified regions and platform. The format for regions without a matching user, the format is the same as get_profile. The stats are returned in a dictionary with a similar format to what https://github.com/SunDwarf/OWAPI/blob/master/api.md#get-apiv3ubattletagstats spec...
[ "Returns", "the", "stats", "for", "the", "profiles", "on", "the", "specified", "regions", "and", "platform", ".", "The", "format", "for", "regions", "without", "a", "matching", "user", "the", "format", "is", "the", "same", "as", "get_profile", ".", "The", ...
train
https://github.com/anthok/overwatch-api/blob/aba976a3c07c4932de13f4236d924b2901b149b9/overwatch_api/core.py#L98-L114
anthok/overwatch-api
overwatch_api/core.py
AsyncOWAPI._base_request
async def _base_request(self, battle_tag: str, endpoint_name: str, session: aiohttp.ClientSession, *, platform=None, handle_ratelimit=None, max_tries=None, request_timeout=None): """Does a request to some endpoint. This is also where ratelimit logic is handled.""" # We check ...
python
async def _base_request(self, battle_tag: str, endpoint_name: str, session: aiohttp.ClientSession, *, platform=None, handle_ratelimit=None, max_tries=None, request_timeout=None): """Does a request to some endpoint. This is also where ratelimit logic is handled.""" # We check ...
[ "async", "def", "_base_request", "(", "self", ",", "battle_tag", ":", "str", ",", "endpoint_name", ":", "str", ",", "session", ":", "aiohttp", ".", "ClientSession", ",", "*", ",", "platform", "=", "None", ",", "handle_ratelimit", "=", "None", ",", "max_tri...
Does a request to some endpoint. This is also where ratelimit logic is handled.
[ "Does", "a", "request", "to", "some", "endpoint", ".", "This", "is", "also", "where", "ratelimit", "logic", "is", "handled", "." ]
train
https://github.com/anthok/overwatch-api/blob/aba976a3c07c4932de13f4236d924b2901b149b9/overwatch_api/core.py#L164-L224
anthok/overwatch-api
overwatch_api/core.py
AsyncOWAPI._async_get
async def _async_get(self, session: aiohttp.ClientSession, *args, _async_timeout_seconds: int = 5, **kwargs): """Uses aiohttp to make a get request asynchronously. Will raise asyncio.TimeoutError if the request could not be completed within _async_timeout_seconds (defa...
python
async def _async_get(self, session: aiohttp.ClientSession, *args, _async_timeout_seconds: int = 5, **kwargs): """Uses aiohttp to make a get request asynchronously. Will raise asyncio.TimeoutError if the request could not be completed within _async_timeout_seconds (defa...
[ "async", "def", "_async_get", "(", "self", ",", "session", ":", "aiohttp", ".", "ClientSession", ",", "*", "args", ",", "_async_timeout_seconds", ":", "int", "=", "5", ",", "*", "*", "kwargs", ")", ":", "# Taken almost directly from the aiohttp tutorial", "with"...
Uses aiohttp to make a get request asynchronously. Will raise asyncio.TimeoutError if the request could not be completed within _async_timeout_seconds (default 5) seconds.
[ "Uses", "aiohttp", "to", "make", "a", "get", "request", "asynchronously", ".", "Will", "raise", "asyncio", ".", "TimeoutError", "if", "the", "request", "could", "not", "be", "completed", "within", "_async_timeout_seconds", "(", "default", "5", ")", "seconds", ...
train
https://github.com/anthok/overwatch-api/blob/aba976a3c07c4932de13f4236d924b2901b149b9/overwatch_api/core.py#L226-L235
Xion/callee
callee/objects.py
is_method
def is_method(arg, min_arity=None, max_arity=None): """Check if argument is a method. Optionally, we can also check if minimum or maximum arities (number of accepted arguments) match given minimum and/or maximum. """ if not callable(arg): return False if not any(is_(arg) for is_ in (in...
python
def is_method(arg, min_arity=None, max_arity=None): """Check if argument is a method. Optionally, we can also check if minimum or maximum arities (number of accepted arguments) match given minimum and/or maximum. """ if not callable(arg): return False if not any(is_(arg) for is_ in (in...
[ "def", "is_method", "(", "arg", ",", "min_arity", "=", "None", ",", "max_arity", "=", "None", ")", ":", "if", "not", "callable", "(", "arg", ")", ":", "return", "False", "if", "not", "any", "(", "is_", "(", "arg", ")", "for", "is_", "in", "(", "i...
Check if argument is a method. Optionally, we can also check if minimum or maximum arities (number of accepted arguments) match given minimum and/or maximum.
[ "Check", "if", "argument", "is", "a", "method", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/objects.py#L115-L154
Xion/callee
callee/objects.py
FileLike._is_readable
def _is_readable(self, obj): """Check if the argument is a readable file-like object.""" try: read = getattr(obj, 'read') except AttributeError: return False else: return is_method(read, max_arity=1)
python
def _is_readable(self, obj): """Check if the argument is a readable file-like object.""" try: read = getattr(obj, 'read') except AttributeError: return False else: return is_method(read, max_arity=1)
[ "def", "_is_readable", "(", "self", ",", "obj", ")", ":", "try", ":", "read", "=", "getattr", "(", "obj", ",", "'read'", ")", "except", "AttributeError", ":", "return", "False", "else", ":", "return", "is_method", "(", "read", ",", "max_arity", "=", "1...
Check if the argument is a readable file-like object.
[ "Check", "if", "the", "argument", "is", "a", "readable", "file", "-", "like", "object", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/objects.py#L85-L92
Xion/callee
callee/objects.py
FileLike._is_writable
def _is_writable(self, obj): """Check if the argument is a writable file-like object.""" try: write = getattr(obj, 'write') except AttributeError: return False else: return is_method(write, min_arity=1, max_arity=1)
python
def _is_writable(self, obj): """Check if the argument is a writable file-like object.""" try: write = getattr(obj, 'write') except AttributeError: return False else: return is_method(write, min_arity=1, max_arity=1)
[ "def", "_is_writable", "(", "self", ",", "obj", ")", ":", "try", ":", "write", "=", "getattr", "(", "obj", ",", "'write'", ")", "except", "AttributeError", ":", "return", "False", "else", ":", "return", "is_method", "(", "write", ",", "min_arity", "=", ...
Check if the argument is a writable file-like object.
[ "Check", "if", "the", "argument", "is", "a", "writable", "file", "-", "like", "object", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/objects.py#L94-L101
scivision/msise00
msise00/base.py
run
def run(time: datetime, altkm: float, glat: Union[float, np.ndarray], glon: Union[float, np.ndarray], *, f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset: """ loops the rungtd1d function below. Figure it's easier to troubleshoot in Python than Fortran. """ glat ...
python
def run(time: datetime, altkm: float, glat: Union[float, np.ndarray], glon: Union[float, np.ndarray], *, f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset: """ loops the rungtd1d function below. Figure it's easier to troubleshoot in Python than Fortran. """ glat ...
[ "def", "run", "(", "time", ":", "datetime", ",", "altkm", ":", "float", ",", "glat", ":", "Union", "[", "float", ",", "np", ".", "ndarray", "]", ",", "glon", ":", "Union", "[", "float", ",", "np", ".", "ndarray", "]", ",", "*", ",", "f107a", ":...
loops the rungtd1d function below. Figure it's easier to troubleshoot in Python than Fortran.
[ "loops", "the", "rungtd1d", "function", "below", ".", "Figure", "it", "s", "easier", "to", "troubleshoot", "in", "Python", "than", "Fortran", "." ]
train
https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/msise00/base.py#L34-L51
scivision/msise00
msise00/base.py
loopalt_gtd
def loopalt_gtd(time: datetime, glat: Union[float, np.ndarray], glon: Union[float, np.ndarray], altkm: Union[float, List[float], np.ndarray], *, f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset: """ loop over location and time time: ...
python
def loopalt_gtd(time: datetime, glat: Union[float, np.ndarray], glon: Union[float, np.ndarray], altkm: Union[float, List[float], np.ndarray], *, f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset: """ loop over location and time time: ...
[ "def", "loopalt_gtd", "(", "time", ":", "datetime", ",", "glat", ":", "Union", "[", "float", ",", "np", ".", "ndarray", "]", ",", "glon", ":", "Union", "[", "float", ",", "np", ".", "ndarray", "]", ",", "altkm", ":", "Union", "[", "float", ",", "...
loop over location and time time: datetime or numpy.datetime64 or list of datetime or np.ndarray of datetime glat: float or 2-D np.ndarray glon: float or 2-D np.ndarray altkm: float or list or 1-D np.ndarray
[ "loop", "over", "location", "and", "time" ]
train
https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/msise00/base.py#L54-L87
scivision/msise00
msise00/base.py
rungtd1d
def rungtd1d(time: datetime, altkm: np.ndarray, glat: float, glon: float, *, f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset: """ This is the "atomic" function looped by other functions """ time = todatetime(time) # %% get solar param...
python
def rungtd1d(time: datetime, altkm: np.ndarray, glat: float, glon: float, *, f107a: float = None, f107: float = None, Ap: int = None) -> xarray.Dataset: """ This is the "atomic" function looped by other functions """ time = todatetime(time) # %% get solar param...
[ "def", "rungtd1d", "(", "time", ":", "datetime", ",", "altkm", ":", "np", ".", "ndarray", ",", "glat", ":", "float", ",", "glon", ":", "float", ",", "*", ",", "f107a", ":", "float", "=", "None", ",", "f107", ":", "float", "=", "None", ",", "Ap", ...
This is the "atomic" function looped by other functions
[ "This", "is", "the", "atomic", "function", "looped", "by", "other", "functions" ]
train
https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/msise00/base.py#L90-L140
Xion/callee
callee/general.py
Matching._validate_desc
def _validate_desc(self, desc): """Validate the predicate description.""" if desc is None: return desc if not isinstance(desc, STRING_TYPES): raise TypeError( "predicate description for Matching must be a string, " "got %r" % (type(desc),)...
python
def _validate_desc(self, desc): """Validate the predicate description.""" if desc is None: return desc if not isinstance(desc, STRING_TYPES): raise TypeError( "predicate description for Matching must be a string, " "got %r" % (type(desc),)...
[ "def", "_validate_desc", "(", "self", ",", "desc", ")", ":", "if", "desc", "is", "None", ":", "return", "desc", "if", "not", "isinstance", "(", "desc", ",", "STRING_TYPES", ")", ":", "raise", "TypeError", "(", "\"predicate description for Matching must be a stri...
Validate the predicate description.
[ "Validate", "the", "predicate", "description", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/general.py#L54-L74
Xion/callee
callee/operators.py
OperatorMatcher._get_placeholder_repr
def _get_placeholder_repr(self): """Return the placeholder part of matcher's ``__repr__``.""" placeholder = '...' if self.TRANSFORM is not None: placeholder = '%s(%s)' % (self.TRANSFORM.__name__, placeholder) return placeholder
python
def _get_placeholder_repr(self): """Return the placeholder part of matcher's ``__repr__``.""" placeholder = '...' if self.TRANSFORM is not None: placeholder = '%s(%s)' % (self.TRANSFORM.__name__, placeholder) return placeholder
[ "def", "_get_placeholder_repr", "(", "self", ")", ":", "placeholder", "=", "'...'", "if", "self", ".", "TRANSFORM", "is", "not", "None", ":", "placeholder", "=", "'%s(%s)'", "%", "(", "self", ".", "TRANSFORM", ".", "__name__", ",", "placeholder", ")", "ret...
Return the placeholder part of matcher's ``__repr__``.
[ "Return", "the", "placeholder", "part", "of", "matcher", "s", "__repr__", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/operators.py#L104-L109
Xion/callee
callee/base.py
BaseMatcherMetaclass._validate_class_definition
def _validate_class_definition(meta, classname, bases, dict_): """Ensure the matcher class definition is acceptable. :raise RuntimeError: If there is a problem """ # let the BaseMatcher class be created without hassle if meta._is_base_matcher_class_definition(classname, dict_): ...
python
def _validate_class_definition(meta, classname, bases, dict_): """Ensure the matcher class definition is acceptable. :raise RuntimeError: If there is a problem """ # let the BaseMatcher class be created without hassle if meta._is_base_matcher_class_definition(classname, dict_): ...
[ "def", "_validate_class_definition", "(", "meta", ",", "classname", ",", "bases", ",", "dict_", ")", ":", "# let the BaseMatcher class be created without hassle", "if", "meta", ".", "_is_base_matcher_class_definition", "(", "classname", ",", "dict_", ")", ":", "return",...
Ensure the matcher class definition is acceptable. :raise RuntimeError: If there is a problem
[ "Ensure", "the", "matcher", "class", "definition", "is", "acceptable", ".", ":", "raise", "RuntimeError", ":", "If", "there", "is", "a", "problem" ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/base.py#L38-L71
Xion/callee
callee/base.py
BaseMatcherMetaclass._is_base_matcher_class_definition
def _is_base_matcher_class_definition(meta, classname, dict_): """Checks whether given class name and dictionary define the :class:`BaseMatcher`. """ if classname != 'BaseMatcher': return False methods = list(filter(inspect.isfunction, dict_.values())) return ...
python
def _is_base_matcher_class_definition(meta, classname, dict_): """Checks whether given class name and dictionary define the :class:`BaseMatcher`. """ if classname != 'BaseMatcher': return False methods = list(filter(inspect.isfunction, dict_.values())) return ...
[ "def", "_is_base_matcher_class_definition", "(", "meta", ",", "classname", ",", "dict_", ")", ":", "if", "classname", "!=", "'BaseMatcher'", ":", "return", "False", "methods", "=", "list", "(", "filter", "(", "inspect", ".", "isfunction", ",", "dict_", ".", ...
Checks whether given class name and dictionary define the :class:`BaseMatcher`.
[ "Checks", "whether", "given", "class", "name", "and", "dictionary", "define", "the", ":", "class", ":", "BaseMatcher", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/base.py#L74-L81
Xion/callee
callee/base.py
BaseMatcherMetaclass._list_magic_methods
def _list_magic_methods(meta, class_): """Return names of magic methods defined by a class. :return: Iterable of magic methods, each w/o the ``__`` prefix/suffix """ return [ name[2:-2] for name, member in class_.__dict__.items() if len(name) > 4 and name.startswi...
python
def _list_magic_methods(meta, class_): """Return names of magic methods defined by a class. :return: Iterable of magic methods, each w/o the ``__`` prefix/suffix """ return [ name[2:-2] for name, member in class_.__dict__.items() if len(name) > 4 and name.startswi...
[ "def", "_list_magic_methods", "(", "meta", ",", "class_", ")", ":", "return", "[", "name", "[", "2", ":", "-", "2", "]", "for", "name", ",", "member", "in", "class_", ".", "__dict__", ".", "items", "(", ")", "if", "len", "(", "name", ")", ">", "4...
Return names of magic methods defined by a class. :return: Iterable of magic methods, each w/o the ``__`` prefix/suffix
[ "Return", "names", "of", "magic", "methods", "defined", "by", "a", "class", ".", ":", "return", ":", "Iterable", "of", "magic", "methods", "each", "w", "/", "o", "the", "__", "prefix", "/", "suffix" ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/base.py#L84-L92
podhmo/python-semver
semver/__init__.py
semver
def semver(version, loose): if isinstance(version, SemVer): if version.loose == loose: return version else: version = version.version elif not isinstance(version, str): # xxx: raise InvalidTypeIncluded("must be str, but {!r}".format(version)) """ if (!(t...
python
def semver(version, loose): if isinstance(version, SemVer): if version.loose == loose: return version else: version = version.version elif not isinstance(version, str): # xxx: raise InvalidTypeIncluded("must be str, but {!r}".format(version)) """ if (!(t...
[ "def", "semver", "(", "version", ",", "loose", ")", ":", "if", "isinstance", "(", "version", ",", "SemVer", ")", ":", "if", "version", ".", "loose", "==", "loose", ":", "return", "version", "else", ":", "version", "=", "version", ".", "version", "elif"...
if (!(this instanceof SemVer)) return new SemVer(version, loose);
[ "if", "(", "!", "(", "this", "instanceof", "SemVer", "))", "return", "new", "SemVer", "(", "version", "loose", ")", ";" ]
train
https://github.com/podhmo/python-semver/blob/46d81c5d70ee716c48c7a8d44f9fefc6b86be33c/semver/__init__.py#L288-L301
Xion/callee
docs/conf.py
autodoc_process_docstring
def autodoc_process_docstring(app, what, name, obj, options, lines): """Handler for the event emitted when autodoc processes a docstring. See http://sphinx-doc.org/ext/autodoc.html#event-autodoc-process-docstring. The TL;DR is that we can modify ``lines`` in-place to influence the output. """ # che...
python
def autodoc_process_docstring(app, what, name, obj, options, lines): """Handler for the event emitted when autodoc processes a docstring. See http://sphinx-doc.org/ext/autodoc.html#event-autodoc-process-docstring. The TL;DR is that we can modify ``lines`` in-place to influence the output. """ # che...
[ "def", "autodoc_process_docstring", "(", "app", ",", "what", ",", "name", ",", "obj", ",", "options", ",", "lines", ")", ":", "# check that only symbols that can be directly imported from ``callee``", "# package are being documented", "_", ",", "symbol", "=", "name", "....
Handler for the event emitted when autodoc processes a docstring. See http://sphinx-doc.org/ext/autodoc.html#event-autodoc-process-docstring. The TL;DR is that we can modify ``lines`` in-place to influence the output.
[ "Handler", "for", "the", "event", "emitted", "when", "autodoc", "processes", "a", "docstring", ".", "See", "http", ":", "//", "sphinx", "-", "doc", ".", "org", "/", "ext", "/", "autodoc", ".", "html#event", "-", "autodoc", "-", "process", "-", "docstring...
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/docs/conf.py#L352-L374
WoLpH/mailjet
mailjet/contrib/django_mailjet/forms.py
SubscriptionForm.clean_email
def clean_email(self): """ Raise ValidationError if the contact exists. """ contacts = self.api.lists.contacts(id=self.list_id)['result'] for contact in contacts: if contact['email'] == self.cleaned_data['email']: raise forms.ValidationError( _(u'...
python
def clean_email(self): """ Raise ValidationError if the contact exists. """ contacts = self.api.lists.contacts(id=self.list_id)['result'] for contact in contacts: if contact['email'] == self.cleaned_data['email']: raise forms.ValidationError( _(u'...
[ "def", "clean_email", "(", "self", ")", ":", "contacts", "=", "self", ".", "api", ".", "lists", ".", "contacts", "(", "id", "=", "self", ".", "list_id", ")", "[", "'result'", "]", "for", "contact", "in", "contacts", ":", "if", "contact", "[", "'email...
Raise ValidationError if the contact exists.
[ "Raise", "ValidationError", "if", "the", "contact", "exists", "." ]
train
https://github.com/WoLpH/mailjet/blob/f7f5102bf52be6a4a9c62afe474387481c806e27/mailjet/contrib/django_mailjet/forms.py#L23-L32
WoLpH/mailjet
mailjet/contrib/django_mailjet/forms.py
SubscriptionForm.add_contact
def add_contact(self): """ Create a contact with using the email on the list. """ self.api.lists.addcontact( contact=self.cleaned_data['email'], id=self.list_id, method='POST')
python
def add_contact(self): """ Create a contact with using the email on the list. """ self.api.lists.addcontact( contact=self.cleaned_data['email'], id=self.list_id, method='POST')
[ "def", "add_contact", "(", "self", ")", ":", "self", ".", "api", ".", "lists", ".", "addcontact", "(", "contact", "=", "self", ".", "cleaned_data", "[", "'email'", "]", ",", "id", "=", "self", ".", "list_id", ",", "method", "=", "'POST'", ")" ]
Create a contact with using the email on the list.
[ "Create", "a", "contact", "with", "using", "the", "email", "on", "the", "list", "." ]
train
https://github.com/WoLpH/mailjet/blob/f7f5102bf52be6a4a9c62afe474387481c806e27/mailjet/contrib/django_mailjet/forms.py#L38-L41
WoLpH/mailjet
mailjet/contrib/django_mailjet/forms.py
SubscriptionForm.api
def api(self): """ Get or create an Api() instance using django settings. """ api = getattr(self, '_api', None) if api is None: self._api = mailjet.Api() return self._api
python
def api(self): """ Get or create an Api() instance using django settings. """ api = getattr(self, '_api', None) if api is None: self._api = mailjet.Api() return self._api
[ "def", "api", "(", "self", ")", ":", "api", "=", "getattr", "(", "self", ",", "'_api'", ",", "None", ")", "if", "api", "is", "None", ":", "self", ".", "_api", "=", "mailjet", ".", "Api", "(", ")", "return", "self", ".", "_api" ]
Get or create an Api() instance using django settings.
[ "Get", "or", "create", "an", "Api", "()", "instance", "using", "django", "settings", "." ]
train
https://github.com/WoLpH/mailjet/blob/f7f5102bf52be6a4a9c62afe474387481c806e27/mailjet/contrib/django_mailjet/forms.py#L44-L51
WoLpH/mailjet
mailjet/contrib/django_mailjet/forms.py
SubscriptionForm.list_id
def list_id(self): """ Get or create the list id. """ list_id = getattr(self, '_list_id', None) if list_id is None: for l in self.api.lists.all()['lists']: if l['name'] == self.list_name: self._list_id = l['id'] if not getattr(self, '...
python
def list_id(self): """ Get or create the list id. """ list_id = getattr(self, '_list_id', None) if list_id is None: for l in self.api.lists.all()['lists']: if l['name'] == self.list_name: self._list_id = l['id'] if not getattr(self, '...
[ "def", "list_id", "(", "self", ")", ":", "list_id", "=", "getattr", "(", "self", ",", "'_list_id'", ",", "None", ")", "if", "list_id", "is", "None", ":", "for", "l", "in", "self", ".", "api", ".", "lists", ".", "all", "(", ")", "[", "'lists'", "]...
Get or create the list id.
[ "Get", "or", "create", "the", "list", "id", "." ]
train
https://github.com/WoLpH/mailjet/blob/f7f5102bf52be6a4a9c62afe474387481c806e27/mailjet/contrib/django_mailjet/forms.py#L54-L68
Xion/callee
callee/_compat.py
getargspec
def getargspec(obj): """Portable version of inspect.getargspec(). Necessary because the original is no longer available starting from Python 3.6. :return: 4-tuple of (argnames, varargname, kwargname, defaults) Note that distinction between positional-or-keyword and keyword-only parameters wil...
python
def getargspec(obj): """Portable version of inspect.getargspec(). Necessary because the original is no longer available starting from Python 3.6. :return: 4-tuple of (argnames, varargname, kwargname, defaults) Note that distinction between positional-or-keyword and keyword-only parameters wil...
[ "def", "getargspec", "(", "obj", ")", ":", "try", ":", "return", "inspect", ".", "getargspec", "(", "obj", ")", "except", "AttributeError", ":", "pass", "# we let a TypeError through", "# translate the signature object back into the 4-tuple", "argnames", "=", "[", "]"...
Portable version of inspect.getargspec(). Necessary because the original is no longer available starting from Python 3.6. :return: 4-tuple of (argnames, varargname, kwargname, defaults) Note that distinction between positional-or-keyword and keyword-only parameters will be lost, as the original g...
[ "Portable", "version", "of", "inspect", ".", "getargspec", "()", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/callee/_compat.py#L81-L112
Xion/callee
setup.py
read_tags
def read_tags(filename): """Reads values of "magic tags" defined in the given Python file. :param filename: Python filename to read the tags from :return: Dictionary of tags """ with open(filename) as f: ast_tree = ast.parse(f.read(), filename) res = {} for node in ast.walk(ast_tre...
python
def read_tags(filename): """Reads values of "magic tags" defined in the given Python file. :param filename: Python filename to read the tags from :return: Dictionary of tags """ with open(filename) as f: ast_tree = ast.parse(f.read(), filename) res = {} for node in ast.walk(ast_tre...
[ "def", "read_tags", "(", "filename", ")", ":", "with", "open", "(", "filename", ")", "as", "f", ":", "ast_tree", "=", "ast", ".", "parse", "(", "f", ".", "read", "(", ")", ",", "filename", ")", "res", "=", "{", "}", "for", "node", "in", "ast", ...
Reads values of "magic tags" defined in the given Python file. :param filename: Python filename to read the tags from :return: Dictionary of tags
[ "Reads", "values", "of", "magic", "tags", "defined", "in", "the", "given", "Python", "file", "." ]
train
https://github.com/Xion/callee/blob/58740f73ff9a76f5fe0075bf18d7345a0f9d961c/setup.py#L16-L39
MichaelAquilina/hashedindex
hashedindex/textparser.py
normalize_unicode
def normalize_unicode(text): """ Normalize any unicode characters to ascii equivalent https://docs.python.org/2/library/unicodedata.html#unicodedata.normalize """ if isinstance(text, six.text_type): return unicodedata.normalize('NFKD', text).encode('ascii', 'ignore').decode('utf8') else:...
python
def normalize_unicode(text): """ Normalize any unicode characters to ascii equivalent https://docs.python.org/2/library/unicodedata.html#unicodedata.normalize """ if isinstance(text, six.text_type): return unicodedata.normalize('NFKD', text).encode('ascii', 'ignore').decode('utf8') else:...
[ "def", "normalize_unicode", "(", "text", ")", ":", "if", "isinstance", "(", "text", ",", "six", ".", "text_type", ")", ":", "return", "unicodedata", ".", "normalize", "(", "'NFKD'", ",", "text", ")", ".", "encode", "(", "'ascii'", ",", "'ignore'", ")", ...
Normalize any unicode characters to ascii equivalent https://docs.python.org/2/library/unicodedata.html#unicodedata.normalize
[ "Normalize", "any", "unicode", "characters", "to", "ascii", "equivalent", "https", ":", "//", "docs", ".", "python", ".", "org", "/", "2", "/", "library", "/", "unicodedata", ".", "html#unicodedata", ".", "normalize" ]
train
https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/textparser.py#L51-L59
MichaelAquilina/hashedindex
hashedindex/textparser.py
word_tokenize
def word_tokenize(text, stopwords=_stopwords, ngrams=None, min_length=0, ignore_numeric=True): """ Parses the given text and yields tokens which represent words within the given text. Tokens are assumed to be divided by any form of whitespace character. """ if ngrams is None: ngrams = 1 ...
python
def word_tokenize(text, stopwords=_stopwords, ngrams=None, min_length=0, ignore_numeric=True): """ Parses the given text and yields tokens which represent words within the given text. Tokens are assumed to be divided by any form of whitespace character. """ if ngrams is None: ngrams = 1 ...
[ "def", "word_tokenize", "(", "text", ",", "stopwords", "=", "_stopwords", ",", "ngrams", "=", "None", ",", "min_length", "=", "0", ",", "ignore_numeric", "=", "True", ")", ":", "if", "ngrams", "is", "None", ":", "ngrams", "=", "1", "text", "=", "re", ...
Parses the given text and yields tokens which represent words within the given text. Tokens are assumed to be divided by any form of whitespace character.
[ "Parses", "the", "given", "text", "and", "yields", "tokens", "which", "represent", "words", "within", "the", "given", "text", ".", "Tokens", "are", "assumed", "to", "be", "divided", "by", "any", "form", "of", "whitespace", "character", "." ]
train
https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/textparser.py#L67-L89
scivision/msise00
msise00/build.py
cmake_setup
def cmake_setup(): """ attempt to build using CMake >= 3 """ cmake_exe = shutil.which('cmake') if not cmake_exe: raise FileNotFoundError('CMake not available') wopts = ['-G', 'MinGW Makefiles', '-DCMAKE_SH="CMAKE_SH-NOTFOUND'] if os.name == 'nt' else [] subprocess.check_call([cmake...
python
def cmake_setup(): """ attempt to build using CMake >= 3 """ cmake_exe = shutil.which('cmake') if not cmake_exe: raise FileNotFoundError('CMake not available') wopts = ['-G', 'MinGW Makefiles', '-DCMAKE_SH="CMAKE_SH-NOTFOUND'] if os.name == 'nt' else [] subprocess.check_call([cmake...
[ "def", "cmake_setup", "(", ")", ":", "cmake_exe", "=", "shutil", ".", "which", "(", "'cmake'", ")", "if", "not", "cmake_exe", ":", "raise", "FileNotFoundError", "(", "'CMake not available'", ")", "wopts", "=", "[", "'-G'", ",", "'MinGW Makefiles'", ",", "'-D...
attempt to build using CMake >= 3
[ "attempt", "to", "build", "using", "CMake", ">", "=", "3" ]
train
https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/msise00/build.py#L27-L44
scivision/msise00
msise00/build.py
meson_setup
def meson_setup(): """ attempt to build with Meson + Ninja """ meson_exe = shutil.which('meson') ninja_exe = shutil.which('ninja') if not meson_exe or not ninja_exe: raise FileNotFoundError('Meson or Ninja not available') if not (BINDIR / 'build.ninja').is_file(): subproces...
python
def meson_setup(): """ attempt to build with Meson + Ninja """ meson_exe = shutil.which('meson') ninja_exe = shutil.which('ninja') if not meson_exe or not ninja_exe: raise FileNotFoundError('Meson or Ninja not available') if not (BINDIR / 'build.ninja').is_file(): subproces...
[ "def", "meson_setup", "(", ")", ":", "meson_exe", "=", "shutil", ".", "which", "(", "'meson'", ")", "ninja_exe", "=", "shutil", ".", "which", "(", "'ninja'", ")", "if", "not", "meson_exe", "or", "not", "ninja_exe", ":", "raise", "FileNotFoundError", "(", ...
attempt to build with Meson + Ninja
[ "attempt", "to", "build", "with", "Meson", "+", "Ninja" ]
train
https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/msise00/build.py#L47-L63
MichaelAquilina/hashedindex
hashedindex/__init__.py
HashedIndex.add_term_occurrence
def add_term_occurrence(self, term, document): """ Adds an occurrence of the term in the specified document. """ if document not in self._documents: self._documents[document] = 0 if term not in self._terms: if self._freeze: return ...
python
def add_term_occurrence(self, term, document): """ Adds an occurrence of the term in the specified document. """ if document not in self._documents: self._documents[document] = 0 if term not in self._terms: if self._freeze: return ...
[ "def", "add_term_occurrence", "(", "self", ",", "term", ",", "document", ")", ":", "if", "document", "not", "in", "self", ".", "_documents", ":", "self", ".", "_documents", "[", "document", "]", "=", "0", "if", "term", "not", "in", "self", ".", "_terms...
Adds an occurrence of the term in the specified document.
[ "Adds", "an", "occurrence", "of", "the", "term", "in", "the", "specified", "document", "." ]
train
https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L69-L86
MichaelAquilina/hashedindex
hashedindex/__init__.py
HashedIndex.get_total_term_frequency
def get_total_term_frequency(self, term): """ Gets the frequency of the specified term in the entire corpus added to the HashedIndex. """ if term not in self._terms: raise IndexError(TERM_DOES_NOT_EXIST) return sum(self._terms[term].values())
python
def get_total_term_frequency(self, term): """ Gets the frequency of the specified term in the entire corpus added to the HashedIndex. """ if term not in self._terms: raise IndexError(TERM_DOES_NOT_EXIST) return sum(self._terms[term].values())
[ "def", "get_total_term_frequency", "(", "self", ",", "term", ")", ":", "if", "term", "not", "in", "self", ".", "_terms", ":", "raise", "IndexError", "(", "TERM_DOES_NOT_EXIST", ")", "return", "sum", "(", "self", ".", "_terms", "[", "term", "]", ".", "val...
Gets the frequency of the specified term in the entire corpus added to the HashedIndex.
[ "Gets", "the", "frequency", "of", "the", "specified", "term", "in", "the", "entire", "corpus", "added", "to", "the", "HashedIndex", "." ]
train
https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L88-L96
MichaelAquilina/hashedindex
hashedindex/__init__.py
HashedIndex.get_term_frequency
def get_term_frequency(self, term, document, normalized=False): """ Returns the frequency of the term specified in the document. """ if document not in self._documents: raise IndexError(DOCUMENT_DOES_NOT_EXIST) if term not in self._terms: raise IndexError...
python
def get_term_frequency(self, term, document, normalized=False): """ Returns the frequency of the term specified in the document. """ if document not in self._documents: raise IndexError(DOCUMENT_DOES_NOT_EXIST) if term not in self._terms: raise IndexError...
[ "def", "get_term_frequency", "(", "self", ",", "term", ",", "document", ",", "normalized", "=", "False", ")", ":", "if", "document", "not", "in", "self", ".", "_documents", ":", "raise", "IndexError", "(", "DOCUMENT_DOES_NOT_EXIST", ")", "if", "term", "not",...
Returns the frequency of the term specified in the document.
[ "Returns", "the", "frequency", "of", "the", "term", "specified", "in", "the", "document", "." ]
train
https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L98-L112
MichaelAquilina/hashedindex
hashedindex/__init__.py
HashedIndex.get_document_frequency
def get_document_frequency(self, term): """ Returns the number of documents the specified term appears in. """ if term not in self._terms: raise IndexError(TERM_DOES_NOT_EXIST) else: return len(self._terms[term])
python
def get_document_frequency(self, term): """ Returns the number of documents the specified term appears in. """ if term not in self._terms: raise IndexError(TERM_DOES_NOT_EXIST) else: return len(self._terms[term])
[ "def", "get_document_frequency", "(", "self", ",", "term", ")", ":", "if", "term", "not", "in", "self", ".", "_terms", ":", "raise", "IndexError", "(", "TERM_DOES_NOT_EXIST", ")", "else", ":", "return", "len", "(", "self", ".", "_terms", "[", "term", "]"...
Returns the number of documents the specified term appears in.
[ "Returns", "the", "number", "of", "documents", "the", "specified", "term", "appears", "in", "." ]
train
https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L114-L121
MichaelAquilina/hashedindex
hashedindex/__init__.py
HashedIndex.get_document_length
def get_document_length(self, document): """ Returns the number of terms found within the specified document. """ if document in self._documents: return self._documents[document] else: raise IndexError(DOCUMENT_DOES_NOT_EXIST)
python
def get_document_length(self, document): """ Returns the number of terms found within the specified document. """ if document in self._documents: return self._documents[document] else: raise IndexError(DOCUMENT_DOES_NOT_EXIST)
[ "def", "get_document_length", "(", "self", ",", "document", ")", ":", "if", "document", "in", "self", ".", "_documents", ":", "return", "self", ".", "_documents", "[", "document", "]", "else", ":", "raise", "IndexError", "(", "DOCUMENT_DOES_NOT_EXIST", ")" ]
Returns the number of terms found within the specified document.
[ "Returns", "the", "number", "of", "terms", "found", "within", "the", "specified", "document", "." ]
train
https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L123-L130
MichaelAquilina/hashedindex
hashedindex/__init__.py
HashedIndex.get_documents
def get_documents(self, term): """ Returns all documents related to the specified term in the form of a Counter object. """ if term not in self._terms: raise IndexError(TERM_DOES_NOT_EXIST) else: return self._terms[term]
python
def get_documents(self, term): """ Returns all documents related to the specified term in the form of a Counter object. """ if term not in self._terms: raise IndexError(TERM_DOES_NOT_EXIST) else: return self._terms[term]
[ "def", "get_documents", "(", "self", ",", "term", ")", ":", "if", "term", "not", "in", "self", ".", "_terms", ":", "raise", "IndexError", "(", "TERM_DOES_NOT_EXIST", ")", "else", ":", "return", "self", ".", "_terms", "[", "term", "]" ]
Returns all documents related to the specified term in the form of a Counter object.
[ "Returns", "all", "documents", "related", "to", "the", "specified", "term", "in", "the", "form", "of", "a", "Counter", "object", "." ]
train
https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L132-L140
MichaelAquilina/hashedindex
hashedindex/__init__.py
HashedIndex.get_tfidf
def get_tfidf(self, term, document, normalized=False): """ Returns the Term-Frequency Inverse-Document-Frequency value for the given term in the specified document. If normalized is True, term frequency will be divided by the document length. """ tf = self.get_term_freque...
python
def get_tfidf(self, term, document, normalized=False): """ Returns the Term-Frequency Inverse-Document-Frequency value for the given term in the specified document. If normalized is True, term frequency will be divided by the document length. """ tf = self.get_term_freque...
[ "def", "get_tfidf", "(", "self", ",", "term", ",", "document", ",", "normalized", "=", "False", ")", ":", "tf", "=", "self", ".", "get_term_frequency", "(", "term", ",", "document", ")", "# Speeds up performance by avoiding extra calculations", "if", "tf", "!=",...
Returns the Term-Frequency Inverse-Document-Frequency value for the given term in the specified document. If normalized is True, term frequency will be divided by the document length.
[ "Returns", "the", "Term", "-", "Frequency", "Inverse", "-", "Document", "-", "Frequency", "value", "for", "the", "given", "term", "in", "the", "specified", "document", ".", "If", "normalized", "is", "True", "term", "frequency", "will", "be", "divided", "by",...
train
https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L151-L171
MichaelAquilina/hashedindex
hashedindex/__init__.py
HashedIndex.generate_document_vector
def generate_document_vector(self, doc, mode='tfidf'): """ Returns a representation of the specified document as a feature vector weighted according the mode specified (by default tf-dif). A custom weighting function can also be passed which receives the hashedindex instance, th...
python
def generate_document_vector(self, doc, mode='tfidf'): """ Returns a representation of the specified document as a feature vector weighted according the mode specified (by default tf-dif). A custom weighting function can also be passed which receives the hashedindex instance, th...
[ "def", "generate_document_vector", "(", "self", ",", "doc", ",", "mode", "=", "'tfidf'", ")", ":", "if", "mode", "==", "'tfidf'", ":", "selected_function", "=", "HashedIndex", ".", "get_tfidf", "elif", "mode", "==", "'ntfidf'", ":", "selected_function", "=", ...
Returns a representation of the specified document as a feature vector weighted according the mode specified (by default tf-dif). A custom weighting function can also be passed which receives the hashedindex instance, the selected term and document as parameters. The result will be ret...
[ "Returns", "a", "representation", "of", "the", "specified", "document", "as", "a", "feature", "vector", "weighted", "according", "the", "mode", "specified", "(", "by", "default", "tf", "-", "dif", ")", "." ]
train
https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L179-L212
MichaelAquilina/hashedindex
hashedindex/__init__.py
HashedIndex.generate_feature_matrix
def generate_feature_matrix(self, mode='tfidf'): """ Returns a feature matrix in the form of a list of lists which represents the terms and documents in this Inverted Index using the tf-idf weighting by default. The term counts in each document can alternatively be used by specif...
python
def generate_feature_matrix(self, mode='tfidf'): """ Returns a feature matrix in the form of a list of lists which represents the terms and documents in this Inverted Index using the tf-idf weighting by default. The term counts in each document can alternatively be used by specif...
[ "def", "generate_feature_matrix", "(", "self", ",", "mode", "=", "'tfidf'", ")", ":", "result", "=", "[", "]", "for", "doc", "in", "self", ".", "_documents", ":", "result", ".", "append", "(", "self", ".", "generate_document_vector", "(", "doc", ",", "mo...
Returns a feature matrix in the form of a list of lists which represents the terms and documents in this Inverted Index using the tf-idf weighting by default. The term counts in each document can alternatively be used by specifying scheme='count'. A custom weighting function can also be...
[ "Returns", "a", "feature", "matrix", "in", "the", "form", "of", "a", "list", "of", "lists", "which", "represents", "the", "terms", "and", "documents", "in", "this", "Inverted", "Index", "using", "the", "tf", "-", "idf", "weighting", "by", "default", ".", ...
train
https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L214-L236
bkeating/python-payflowpro
payflowpro/client.py
find_class_in_list
def find_class_in_list(klass, lst): """ Returns the first occurrence of an instance of type `klass` in the given list, or None if no such instance is present. """ filtered = list(filter(lambda x: x.__class__ == klass, lst)) if filtered: return filtered[0] return None
python
def find_class_in_list(klass, lst): """ Returns the first occurrence of an instance of type `klass` in the given list, or None if no such instance is present. """ filtered = list(filter(lambda x: x.__class__ == klass, lst)) if filtered: return filtered[0] return None
[ "def", "find_class_in_list", "(", "klass", ",", "lst", ")", ":", "filtered", "=", "list", "(", "filter", "(", "lambda", "x", ":", "x", ".", "__class__", "==", "klass", ",", "lst", ")", ")", "if", "filtered", ":", "return", "filtered", "[", "0", "]", ...
Returns the first occurrence of an instance of type `klass` in the given list, or None if no such instance is present.
[ "Returns", "the", "first", "occurrence", "of", "an", "instance", "of", "type", "klass", "in", "the", "given", "list", "or", "None", "if", "no", "such", "instance", "is", "present", "." ]
train
https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/client.py#L400-L408
bkeating/python-payflowpro
payflowpro/client.py
find_classes_in_list
def find_classes_in_list(klasses, lst): """ Returns a tuple containing an entry corresponding to each of the requested class types, where the entry is either the first object instance of that type or None of no such instances are available. Example Usage: find_classes_in_list( ...
python
def find_classes_in_list(klasses, lst): """ Returns a tuple containing an entry corresponding to each of the requested class types, where the entry is either the first object instance of that type or None of no such instances are available. Example Usage: find_classes_in_list( ...
[ "def", "find_classes_in_list", "(", "klasses", ",", "lst", ")", ":", "if", "not", "isinstance", "(", "klasses", ",", "list", ")", ":", "klasses", "=", "[", "klasses", "]", "return", "tuple", "(", "map", "(", "lambda", "klass", ":", "find_class_in_list", ...
Returns a tuple containing an entry corresponding to each of the requested class types, where the entry is either the first object instance of that type or None of no such instances are available. Example Usage: find_classes_in_list( [Address, Response], [<classes.Response....
[ "Returns", "a", "tuple", "containing", "an", "entry", "corresponding", "to", "each", "of", "the", "requested", "class", "types", "where", "the", "entry", "is", "either", "the", "first", "object", "instance", "of", "that", "type", "or", "None", "of", "no", ...
train
https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/client.py#L410-L427
bkeating/python-payflowpro
payflowpro/client.py
PayflowProClient._build_parmlist
def _build_parmlist(self, parameters): """ Converts a dictionary of name and value pairs into a PARMLIST string value acceptable to the Payflow Pro API. """ args = [] for key, value in parameters.items(): if not value is None: # We always us...
python
def _build_parmlist(self, parameters): """ Converts a dictionary of name and value pairs into a PARMLIST string value acceptable to the Payflow Pro API. """ args = [] for key, value in parameters.items(): if not value is None: # We always us...
[ "def", "_build_parmlist", "(", "self", ",", "parameters", ")", ":", "args", "=", "[", "]", "for", "key", ",", "value", "in", "parameters", ".", "items", "(", ")", ":", "if", "not", "value", "is", "None", ":", "# We always use the explicit-length keyname form...
Converts a dictionary of name and value pairs into a PARMLIST string value acceptable to the Payflow Pro API.
[ "Converts", "a", "dictionary", "of", "name", "and", "value", "pairs", "into", "a", "PARMLIST", "string", "value", "acceptable", "to", "the", "Payflow", "Pro", "API", "." ]
train
https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/client.py#L106-L131
bkeating/python-payflowpro
payflowpro/client.py
PayflowProClient._parse_parmlist
def _parse_parmlist(self, parmlist): """ Parses a PARMLIST string into a dictionary of name and value pairs. The parsing is complicated by the following: - parameter keynames may or may not include a length specification - delimiter characters (=, &) may a...
python
def _parse_parmlist(self, parmlist): """ Parses a PARMLIST string into a dictionary of name and value pairs. The parsing is complicated by the following: - parameter keynames may or may not include a length specification - delimiter characters (=, &) may a...
[ "def", "_parse_parmlist", "(", "self", ",", "parmlist", ")", ":", "parmlist", "=", "\"&\"", "+", "parmlist", "name_re", "=", "re", ".", "compile", "(", "r'\\&([A-Z0-9_]+)(\\[\\d+\\])?='", ")", "results", "=", "{", "}", "offset", "=", "0", "match", "=", "na...
Parses a PARMLIST string into a dictionary of name and value pairs. The parsing is complicated by the following: - parameter keynames may or may not include a length specification - delimiter characters (=, &) may appear inside parameter values, provided the pa...
[ "Parses", "a", "PARMLIST", "string", "into", "a", "dictionary", "of", "name", "and", "value", "pairs", ".", "The", "parsing", "is", "complicated", "by", "the", "following", ":", "-", "parameter", "keynames", "may", "or", "may", "not", "include", "a", "leng...
train
https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/client.py#L133-L174
damianbraun/nominatim
nominatim/nominatim.py
NominatimRequest.request
def request(self, url): """ Send a http request to the given *url*, try to decode the reply assuming it's JSON in UTF-8, and return the result :returns: Decoded result, or None in case of an error :rtype: mixed """ self.logger.debug('url:\n' + url) try: ...
python
def request(self, url): """ Send a http request to the given *url*, try to decode the reply assuming it's JSON in UTF-8, and return the result :returns: Decoded result, or None in case of an error :rtype: mixed """ self.logger.debug('url:\n' + url) try: ...
[ "def", "request", "(", "self", ",", "url", ")", ":", "self", ".", "logger", ".", "debug", "(", "'url:\\n'", "+", "url", ")", "try", ":", "response", "=", "urlopen", "(", "url", ")", "return", "json", ".", "loads", "(", "response", ".", "read", "(",...
Send a http request to the given *url*, try to decode the reply assuming it's JSON in UTF-8, and return the result :returns: Decoded result, or None in case of an error :rtype: mixed
[ "Send", "a", "http", "request", "to", "the", "given", "*", "url", "*", "try", "to", "decode", "the", "reply", "assuming", "it", "s", "JSON", "in", "UTF", "-", "8", "and", "return", "the", "result" ]
train
https://github.com/damianbraun/nominatim/blob/d3cc40e1d31755aabf7302a617ab6e982eeb9b4f/nominatim/nominatim.py#L58-L73
damianbraun/nominatim
nominatim/nominatim.py
Nominatim.query
def query(self, address, acceptlanguage=None, limit=20, countrycodes=None): """ Issue a geocoding query for *address* to the Nominatim instance and return the decoded results :param address: a query string with an address or presumed parts of an add...
python
def query(self, address, acceptlanguage=None, limit=20, countrycodes=None): """ Issue a geocoding query for *address* to the Nominatim instance and return the decoded results :param address: a query string with an address or presumed parts of an add...
[ "def", "query", "(", "self", ",", "address", ",", "acceptlanguage", "=", "None", ",", "limit", "=", "20", ",", "countrycodes", "=", "None", ")", ":", "url", "=", "self", ".", "url", "+", "'&q='", "+", "quote_plus", "(", "address", ")", "if", "acceptl...
Issue a geocoding query for *address* to the Nominatim instance and return the decoded results :param address: a query string with an address or presumed parts of an address :type address: str or (if python2) unicode :param acceptlanguage: rfc2616 language code ...
[ "Issue", "a", "geocoding", "query", "for", "*", "address", "*", "to", "the", "Nominatim", "instance", "and", "return", "the", "decoded", "results" ]
train
https://github.com/damianbraun/nominatim/blob/d3cc40e1d31755aabf7302a617ab6e982eeb9b4f/nominatim/nominatim.py#L92-L119
damianbraun/nominatim
nominatim/nominatim.py
NominatimReverse.query
def query(self, lat=None, lon=None, osm_id=None, osm_type=None, acceptlanguage='', zoom=18): """ Issue a reverse geocoding query for a place given by *lat* and *lon*, or by *osm_id* and *osm_type* to the Nominatim instance and return the decoded results :param lat:...
python
def query(self, lat=None, lon=None, osm_id=None, osm_type=None, acceptlanguage='', zoom=18): """ Issue a reverse geocoding query for a place given by *lat* and *lon*, or by *osm_id* and *osm_type* to the Nominatim instance and return the decoded results :param lat:...
[ "def", "query", "(", "self", ",", "lat", "=", "None", ",", "lon", "=", "None", ",", "osm_id", "=", "None", ",", "osm_type", "=", "None", ",", "acceptlanguage", "=", "''", ",", "zoom", "=", "18", ")", ":", "url", "=", "self", ".", "url", "if", "...
Issue a reverse geocoding query for a place given by *lat* and *lon*, or by *osm_id* and *osm_type* to the Nominatim instance and return the decoded results :param lat: the geograpical latitude of the place :param lon: the geograpical longitude of the place :param osm_id: openst...
[ "Issue", "a", "reverse", "geocoding", "query", "for", "a", "place", "given", "by", "*", "lat", "*", "and", "*", "lon", "*", "or", "by", "*", "osm_id", "*", "and", "*", "osm_type", "*", "to", "the", "Nominatim", "instance", "and", "return", "the", "de...
train
https://github.com/damianbraun/nominatim/blob/d3cc40e1d31755aabf7302a617ab6e982eeb9b4f/nominatim/nominatim.py#L139-L180
darothen/xbpch
xbpch/grid.py
CTMGrid.from_model
def from_model(cls, model_name, **kwargs): """ Define a grid using the specifications of a given model. Parameters ---------- model_name : string Name the model (see :func:`get_supported_models` for available model names). Supports multiple fo...
python
def from_model(cls, model_name, **kwargs): """ Define a grid using the specifications of a given model. Parameters ---------- model_name : string Name the model (see :func:`get_supported_models` for available model names). Supports multiple fo...
[ "def", "from_model", "(", "cls", ",", "model_name", ",", "*", "*", "kwargs", ")", ":", "settings", "=", "_get_model_info", "(", "model_name", ")", "model", "=", "settings", ".", "pop", "(", "'model_name'", ")", "for", "k", ",", "v", "in", "list", "(", ...
Define a grid using the specifications of a given model. Parameters ---------- model_name : string Name the model (see :func:`get_supported_models` for available model names). Supports multiple formats (e.g., 'GEOS5', 'GEOS-5' or 'GEOS_5'). **kwargs :...
[ "Define", "a", "grid", "using", "the", "specifications", "of", "a", "given", "model", "." ]
train
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L143-L180
darothen/xbpch
xbpch/grid.py
CTMGrid.copy_from_model
def copy_from_model(cls, model_name, reference, **kwargs): """ Set-up a user-defined grid using specifications of a reference grid model. Parameters ---------- model_name : string name of the user-defined grid model. reference : string or :class:`CTMG...
python
def copy_from_model(cls, model_name, reference, **kwargs): """ Set-up a user-defined grid using specifications of a reference grid model. Parameters ---------- model_name : string name of the user-defined grid model. reference : string or :class:`CTMG...
[ "def", "copy_from_model", "(", "cls", ",", "model_name", ",", "reference", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "reference", ",", "cls", ")", ":", "settings", "=", "reference", ".", "__dict__", ".", "copy", "(", ")", "settings", ...
Set-up a user-defined grid using specifications of a reference grid model. Parameters ---------- model_name : string name of the user-defined grid model. reference : string or :class:`CTMGrid` instance Name of the reference model (see :func:`get_supported...
[ "Set", "-", "up", "a", "user", "-", "defined", "grid", "using", "specifications", "of", "a", "reference", "grid", "model", "." ]
train
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L183-L214
darothen/xbpch
xbpch/grid.py
CTMGrid.get_layers
def get_layers(self, Psurf=1013.25, Ptop=0.01, **kwargs): """ Compute scalars or coordinates associated to the vertical layers. Parameters ---------- grid_spec : CTMGrid object CTMGrid containing the information necessary to re-construct grid levels for a...
python
def get_layers(self, Psurf=1013.25, Ptop=0.01, **kwargs): """ Compute scalars or coordinates associated to the vertical layers. Parameters ---------- grid_spec : CTMGrid object CTMGrid containing the information necessary to re-construct grid levels for a...
[ "def", "get_layers", "(", "self", ",", "Psurf", "=", "1013.25", ",", "Ptop", "=", "0.01", ",", "*", "*", "kwargs", ")", ":", "Psurf", "=", "np", ".", "asarray", "(", "Psurf", ")", "output_ndims", "=", "Psurf", ".", "ndim", "+", "1", "if", "output_n...
Compute scalars or coordinates associated to the vertical layers. Parameters ---------- grid_spec : CTMGrid object CTMGrid containing the information necessary to re-construct grid levels for a given model coordinate system. Returns ------- dicti...
[ "Compute", "scalars", "or", "coordinates", "associated", "to", "the", "vertical", "layers", "." ]
train
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L217-L324
darothen/xbpch
xbpch/grid.py
CTMGrid.get_lonlat
def get_lonlat(self): """ Calculate longitude-latitude grid for a specified resolution and configuration / ordering. Parameters ---------- rlon, rlat : float Resolution (in degrees) of longitude and latitude grids. halfpolar : bool (default=True) ...
python
def get_lonlat(self): """ Calculate longitude-latitude grid for a specified resolution and configuration / ordering. Parameters ---------- rlon, rlat : float Resolution (in degrees) of longitude and latitude grids. halfpolar : bool (default=True) ...
[ "def", "get_lonlat", "(", "self", ")", ":", "rlon", ",", "rlat", "=", "self", ".", "resolution", "# Compute number of grid cells in each direction", "Nlon", "=", "int", "(", "360.", "/", "rlon", ")", "Nlat", "=", "int", "(", "180.", "/", "rlat", ")", "+", ...
Calculate longitude-latitude grid for a specified resolution and configuration / ordering. Parameters ---------- rlon, rlat : float Resolution (in degrees) of longitude and latitude grids. halfpolar : bool (default=True) Polar grid boxes span half of rlat...
[ "Calculate", "longitude", "-", "latitude", "grid", "for", "a", "specified", "resolution", "and", "configuration", "/", "ordering", "." ]
train
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L327-L371
openSUSE/py2pack
py2pack/__init__.py
_get_template_dirs
def _get_template_dirs(): """existing directories where to search for jinja2 templates. The order is important. The first found template from the first found dir wins!""" return filter(lambda x: os.path.exists(x), [ # user dir os.path.join(os.path.expanduser('~'), '.py2pack', 'templates'), ...
python
def _get_template_dirs(): """existing directories where to search for jinja2 templates. The order is important. The first found template from the first found dir wins!""" return filter(lambda x: os.path.exists(x), [ # user dir os.path.join(os.path.expanduser('~'), '.py2pack', 'templates'), ...
[ "def", "_get_template_dirs", "(", ")", ":", "return", "filter", "(", "lambda", "x", ":", "os", ".", "path", ".", "exists", "(", "x", ")", ",", "[", "# user dir", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "'~'",...
existing directories where to search for jinja2 templates. The order is important. The first found template from the first found dir wins!
[ "existing", "directories", "where", "to", "search", "for", "jinja2", "templates", ".", "The", "order", "is", "important", ".", "The", "first", "found", "template", "from", "the", "first", "found", "dir", "wins!" ]
train
https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/__init__.py#L53-L63
openSUSE/py2pack
py2pack/__init__.py
_license_from_classifiers
def _license_from_classifiers(data): """try to get a license from the classifiers""" classifiers = data.get('classifiers', []) found_license = None for c in classifiers: if c.startswith("License :: OSI Approved :: "): found_license = c.replace("License :: OSI Approved :: ", "") r...
python
def _license_from_classifiers(data): """try to get a license from the classifiers""" classifiers = data.get('classifiers', []) found_license = None for c in classifiers: if c.startswith("License :: OSI Approved :: "): found_license = c.replace("License :: OSI Approved :: ", "") r...
[ "def", "_license_from_classifiers", "(", "data", ")", ":", "classifiers", "=", "data", ".", "get", "(", "'classifiers'", ",", "[", "]", ")", "found_license", "=", "None", "for", "c", "in", "classifiers", ":", "if", "c", ".", "startswith", "(", "\"License :...
try to get a license from the classifiers
[ "try", "to", "get", "a", "license", "from", "the", "classifiers" ]
train
https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/__init__.py#L177-L184
openSUSE/py2pack
py2pack/__init__.py
_normalize_license
def _normalize_license(data): """try to get SDPX license""" license = data.get('license', None) if not license: # try to get license from classifiers license = _license_from_classifiers(data) if license: if license in SDPX_LICENSES.keys(): data['license'] = SDPX_LICEN...
python
def _normalize_license(data): """try to get SDPX license""" license = data.get('license', None) if not license: # try to get license from classifiers license = _license_from_classifiers(data) if license: if license in SDPX_LICENSES.keys(): data['license'] = SDPX_LICEN...
[ "def", "_normalize_license", "(", "data", ")", ":", "license", "=", "data", ".", "get", "(", "'license'", ",", "None", ")", "if", "not", "license", ":", "# try to get license from classifiers", "license", "=", "_license_from_classifiers", "(", "data", ")", "if",...
try to get SDPX license
[ "try", "to", "get", "SDPX", "license" ]
train
https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/__init__.py#L187-L199
asmeurer/iterm2-tools
iterm2_tools/ipython.py
wrap_prompts_class
def wrap_prompts_class(Klass): """ Wrap an IPython's Prompt class This is needed in order for Prompt to inject the correct escape sequences at the right positions for shell integrations. """ try: from prompt_toolkit.token import ZeroWidthEscape except ImportError: return K...
python
def wrap_prompts_class(Klass): """ Wrap an IPython's Prompt class This is needed in order for Prompt to inject the correct escape sequences at the right positions for shell integrations. """ try: from prompt_toolkit.token import ZeroWidthEscape except ImportError: return K...
[ "def", "wrap_prompts_class", "(", "Klass", ")", ":", "try", ":", "from", "prompt_toolkit", ".", "token", "import", "ZeroWidthEscape", "except", "ImportError", ":", "return", "Klass", "class", "ITerm2IPythonPrompt", "(", "Klass", ")", ":", "def", "in_prompt_tokens"...
Wrap an IPython's Prompt class This is needed in order for Prompt to inject the correct escape sequences at the right positions for shell integrations.
[ "Wrap", "an", "IPython", "s", "Prompt", "class" ]
train
https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/ipython.py#L113-L137
blixt/py-starbound
starbound/btreedb5.py
BTreeDB5.get_all_keys
def get_all_keys(self, start=None): """ A generator which yields a list of all valid keys starting at the given `start` offset. If `start` is `None`, we will start from the root of the tree. """ s = self.stream if not start: start = HEADER_SIZE + self...
python
def get_all_keys(self, start=None): """ A generator which yields a list of all valid keys starting at the given `start` offset. If `start` is `None`, we will start from the root of the tree. """ s = self.stream if not start: start = HEADER_SIZE + self...
[ "def", "get_all_keys", "(", "self", ",", "start", "=", "None", ")", ":", "s", "=", "self", ".", "stream", "if", "not", "start", ":", "start", "=", "HEADER_SIZE", "+", "self", ".", "block_size", "*", "self", ".", "root_block", "s", ".", "seek", "(", ...
A generator which yields a list of all valid keys starting at the given `start` offset. If `start` is `None`, we will start from the root of the tree.
[ "A", "generator", "which", "yields", "a", "list", "of", "all", "valid", "keys", "starting", "at", "the", "given", "start", "offset", ".", "If", "start", "is", "None", "we", "will", "start", "from", "the", "root", "of", "the", "tree", "." ]
train
https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/btreedb5.py#L69-L107
darothen/xbpch
xbpch/uff.py
_replace_star
def _replace_star(fmt, size): """ Replace the `*` placeholder in a format string (fmt), so that struct.calcsize(fmt) is equal to the given `size` using the format following the placeholder. Raises `ValueError` if number of `*` is larger than 1. If no `*` in `fmt`, returns `fmt` without checking...
python
def _replace_star(fmt, size): """ Replace the `*` placeholder in a format string (fmt), so that struct.calcsize(fmt) is equal to the given `size` using the format following the placeholder. Raises `ValueError` if number of `*` is larger than 1. If no `*` in `fmt`, returns `fmt` without checking...
[ "def", "_replace_star", "(", "fmt", ",", "size", ")", ":", "n_stars", "=", "fmt", ".", "count", "(", "'*'", ")", "if", "n_stars", ">", "1", ":", "raise", "ValueError", "(", "\"More than one `*` in format (%s).\"", "%", "fmt", ")", "if", "n_stars", ":", "...
Replace the `*` placeholder in a format string (fmt), so that struct.calcsize(fmt) is equal to the given `size` using the format following the placeholder. Raises `ValueError` if number of `*` is larger than 1. If no `*` in `fmt`, returns `fmt` without checking its size! Examples -------- ...
[ "Replace", "the", "*", "placeholder", "in", "a", "format", "string", "(", "fmt", ")", "so", "that", "struct", ".", "calcsize", "(", "fmt", ")", "is", "equal", "to", "the", "given", "size", "using", "the", "format", "following", "the", "placeholder", "." ...
train
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L160-L186
darothen/xbpch
xbpch/uff.py
FortranFile._fix
def _fix(self, fmt='i'): """ Read pre- or suffix of line at current position with given format `fmt` (default 'i'). """ fmt = self.endian + fmt fix = self.read(struct.calcsize(fmt)) if fix: return struct.unpack(fmt, fix)[0] else: ra...
python
def _fix(self, fmt='i'): """ Read pre- or suffix of line at current position with given format `fmt` (default 'i'). """ fmt = self.endian + fmt fix = self.read(struct.calcsize(fmt)) if fix: return struct.unpack(fmt, fix)[0] else: ra...
[ "def", "_fix", "(", "self", ",", "fmt", "=", "'i'", ")", ":", "fmt", "=", "self", ".", "endian", "+", "fmt", "fix", "=", "self", ".", "read", "(", "struct", ".", "calcsize", "(", "fmt", ")", ")", "if", "fix", ":", "return", "struct", ".", "unpa...
Read pre- or suffix of line at current position with given format `fmt` (default 'i').
[ "Read", "pre", "-", "or", "suffix", "of", "line", "at", "current", "position", "with", "given", "format", "fmt", "(", "default", "i", ")", "." ]
train
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L67-L77
darothen/xbpch
xbpch/uff.py
FortranFile.readline
def readline(self, fmt=None): """ Return next unformatted "line". If format is given, unpack content, otherwise return byte string. """ prefix_size = self._fix() if fmt is None: content = self.read(prefix_size) else: fmt = self.endian + fm...
python
def readline(self, fmt=None): """ Return next unformatted "line". If format is given, unpack content, otherwise return byte string. """ prefix_size = self._fix() if fmt is None: content = self.read(prefix_size) else: fmt = self.endian + fm...
[ "def", "readline", "(", "self", ",", "fmt", "=", "None", ")", ":", "prefix_size", "=", "self", ".", "_fix", "(", ")", "if", "fmt", "is", "None", ":", "content", "=", "self", ".", "read", "(", "prefix_size", ")", "else", ":", "fmt", "=", "self", "...
Return next unformatted "line". If format is given, unpack content, otherwise return byte string.
[ "Return", "next", "unformatted", "line", ".", "If", "format", "is", "given", "unpack", "content", "otherwise", "return", "byte", "string", "." ]
train
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L79-L102
darothen/xbpch
xbpch/uff.py
FortranFile.skipline
def skipline(self): """ Skip the next line and returns position and size of line. Raises IOError if pre- and suffix of line do not match. """ position = self.tell() prefix = self._fix() self.seek(prefix, 1) # skip content suffix = self._fix() if ...
python
def skipline(self): """ Skip the next line and returns position and size of line. Raises IOError if pre- and suffix of line do not match. """ position = self.tell() prefix = self._fix() self.seek(prefix, 1) # skip content suffix = self._fix() if ...
[ "def", "skipline", "(", "self", ")", ":", "position", "=", "self", ".", "tell", "(", ")", "prefix", "=", "self", ".", "_fix", "(", ")", "self", ".", "seek", "(", "prefix", ",", "1", ")", "# skip content", "suffix", "=", "self", ".", "_fix", "(", ...
Skip the next line and returns position and size of line. Raises IOError if pre- and suffix of line do not match.
[ "Skip", "the", "next", "line", "and", "returns", "position", "and", "size", "of", "line", ".", "Raises", "IOError", "if", "pre", "-", "and", "suffix", "of", "line", "do", "not", "match", "." ]
train
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L110-L123
darothen/xbpch
xbpch/uff.py
FortranFile.writeline
def writeline(self, fmt, *args): """ Write `line` (list of objects) with given `fmt` to file. The `line` will be chained if object is iterable (except for basestrings). """ fmt = self.endian + fmt size = struct.calcsize(fmt) fix = struct.pack(self.endian ...
python
def writeline(self, fmt, *args): """ Write `line` (list of objects) with given `fmt` to file. The `line` will be chained if object is iterable (except for basestrings). """ fmt = self.endian + fmt size = struct.calcsize(fmt) fix = struct.pack(self.endian ...
[ "def", "writeline", "(", "self", ",", "fmt", ",", "*", "args", ")", ":", "fmt", "=", "self", ".", "endian", "+", "fmt", "size", "=", "struct", ".", "calcsize", "(", "fmt", ")", "fix", "=", "struct", ".", "pack", "(", "self", ".", "endian", "+", ...
Write `line` (list of objects) with given `fmt` to file. The `line` will be chained if object is iterable (except for basestrings).
[ "Write", "line", "(", "list", "of", "objects", ")", "with", "given", "fmt", "to", "file", ".", "The", "line", "will", "be", "chained", "if", "object", "is", "iterable", "(", "except", "for", "basestrings", ")", "." ]
train
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L125-L139
darothen/xbpch
xbpch/uff.py
FortranFile.writelines
def writelines(self, lines, fmt): """ Write `lines` with given `format`. """ if isinstance(fmt, basestring): fmt = [fmt] * len(lines) for f, line in zip(fmt, lines): self.writeline(f, line, self.endian)
python
def writelines(self, lines, fmt): """ Write `lines` with given `format`. """ if isinstance(fmt, basestring): fmt = [fmt] * len(lines) for f, line in zip(fmt, lines): self.writeline(f, line, self.endian)
[ "def", "writelines", "(", "self", ",", "lines", ",", "fmt", ")", ":", "if", "isinstance", "(", "fmt", ",", "basestring", ")", ":", "fmt", "=", "[", "fmt", "]", "*", "len", "(", "lines", ")", "for", "f", ",", "line", "in", "zip", "(", "fmt", ","...
Write `lines` with given `format`.
[ "Write", "lines", "with", "given", "format", "." ]
train
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L141-L148
blixt/py-starbound
starbound/sbon.py
read_varint
def read_varint(stream): """Read while the most significant bit is set, then put the 7 least significant bits of all read bytes together to create a number. """ value = 0 while True: byte = ord(stream.read(1)) if not byte & 0b10000000: return value << 7 | byte va...
python
def read_varint(stream): """Read while the most significant bit is set, then put the 7 least significant bits of all read bytes together to create a number. """ value = 0 while True: byte = ord(stream.read(1)) if not byte & 0b10000000: return value << 7 | byte va...
[ "def", "read_varint", "(", "stream", ")", ":", "value", "=", "0", "while", "True", ":", "byte", "=", "ord", "(", "stream", ".", "read", "(", "1", ")", ")", "if", "not", "byte", "&", "0b10000000", ":", "return", "value", "<<", "7", "|", "byte", "v...
Read while the most significant bit is set, then put the 7 least significant bits of all read bytes together to create a number.
[ "Read", "while", "the", "most", "significant", "bit", "is", "set", "then", "put", "the", "7", "least", "significant", "bits", "of", "all", "read", "bytes", "together", "to", "create", "a", "number", "." ]
train
https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/sbon.py#L70-L80
darothen/xbpch
xbpch/core.py
open_bpchdataset
def open_bpchdataset(filename, fields=[], categories=[], tracerinfo_file='tracerinfo.dat', diaginfo_file='diaginfo.dat', endian=">", decode_cf=True, memmap=True, dask=True, return_store=False): """ Open a GEOS-Chem BPCH file output ...
python
def open_bpchdataset(filename, fields=[], categories=[], tracerinfo_file='tracerinfo.dat', diaginfo_file='diaginfo.dat', endian=">", decode_cf=True, memmap=True, dask=True, return_store=False): """ Open a GEOS-Chem BPCH file output ...
[ "def", "open_bpchdataset", "(", "filename", ",", "fields", "=", "[", "]", ",", "categories", "=", "[", "]", ",", "tracerinfo_file", "=", "'tracerinfo.dat'", ",", "diaginfo_file", "=", "'diaginfo.dat'", ",", "endian", "=", "\">\"", ",", "decode_cf", "=", "Tru...
Open a GEOS-Chem BPCH file output as an xarray Dataset. Parameters ---------- filename : string Path to the output file to read in. {tracerinfo,diaginfo}_file : string, optional Path to the metadata "info" .dat files which are used to decipher the metadata corresponding to each ...
[ "Open", "a", "GEOS", "-", "Chem", "BPCH", "file", "output", "as", "an", "xarray", "Dataset", "." ]
train
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/core.py#L26-L126
darothen/xbpch
xbpch/core.py
open_mfbpchdataset
def open_mfbpchdataset(paths, concat_dim='time', compat='no_conflicts', preprocess=None, lock=None, **kwargs): """ Open multiple bpch files as a single dataset. You must have dask installed for this to work, as this greatly simplifies issues relating to multi-file I/O. Also, ple...
python
def open_mfbpchdataset(paths, concat_dim='time', compat='no_conflicts', preprocess=None, lock=None, **kwargs): """ Open multiple bpch files as a single dataset. You must have dask installed for this to work, as this greatly simplifies issues relating to multi-file I/O. Also, ple...
[ "def", "open_mfbpchdataset", "(", "paths", ",", "concat_dim", "=", "'time'", ",", "compat", "=", "'no_conflicts'", ",", "preprocess", "=", "None", ",", "lock", "=", "None", ",", "*", "*", "kwargs", ")", ":", "from", "xarray", ".", "backends", ".", "api",...
Open multiple bpch files as a single dataset. You must have dask installed for this to work, as this greatly simplifies issues relating to multi-file I/O. Also, please note that this is not a very performant routine. I/O is still limited by the fact that we need to manually scan/read through each bpch...
[ "Open", "multiple", "bpch", "files", "as", "a", "single", "dataset", "." ]
train
https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/core.py#L129-L215
bitlabstudio/django-multilingual-news
multilingual_news/south_migrations/0006_migrate_placeholder_fields.py
Migration.forwards
def forwards(self, orm): "Write your forwards methods here." # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..." for entry in orm['multilingual_news.NewsEntry'].objects.all(): self.migrate_placeholder( orm, entry, 'excerpt', 'multilin...
python
def forwards(self, orm): "Write your forwards methods here." # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..." for entry in orm['multilingual_news.NewsEntry'].objects.all(): self.migrate_placeholder( orm, entry, 'excerpt', 'multilin...
[ "def", "forwards", "(", "self", ",", "orm", ")", ":", "# Note: Remember to use orm['appname.ModelName'] rather than \"from appname.models...\"", "for", "entry", "in", "orm", "[", "'multilingual_news.NewsEntry'", "]", ".", "objects", ".", "all", "(", ")", ":", "self", ...
Write your forwards methods here.
[ "Write", "your", "forwards", "methods", "here", "." ]
train
https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/south_migrations/0006_migrate_placeholder_fields.py#L35-L42
asmeurer/iterm2-tools
iterm2_tools/images.py
image_bytes
def image_bytes(b, filename=None, inline=1, width='auto', height='auto', preserve_aspect_ratio=None): """ Return a bytes string that displays image given by bytes b in the terminal If filename=None, the filename defaults to "Unnamed file" width and height are strings, following the format ...
python
def image_bytes(b, filename=None, inline=1, width='auto', height='auto', preserve_aspect_ratio=None): """ Return a bytes string that displays image given by bytes b in the terminal If filename=None, the filename defaults to "Unnamed file" width and height are strings, following the format ...
[ "def", "image_bytes", "(", "b", ",", "filename", "=", "None", ",", "inline", "=", "1", ",", "width", "=", "'auto'", ",", "height", "=", "'auto'", ",", "preserve_aspect_ratio", "=", "None", ")", ":", "if", "preserve_aspect_ratio", "is", "None", ":", "if",...
Return a bytes string that displays image given by bytes b in the terminal If filename=None, the filename defaults to "Unnamed file" width and height are strings, following the format N: N character cells. Npx: N pixels. N%: N percent of the session's width or height. 'auto...
[ "Return", "a", "bytes", "string", "that", "displays", "image", "given", "by", "bytes", "b", "in", "the", "terminal" ]
train
https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/images.py#L15-L54
asmeurer/iterm2-tools
iterm2_tools/images.py
display_image_bytes
def display_image_bytes(b, filename=None, inline=1, width='auto', height='auto', preserve_aspect_ratio=None): """ Display the image given by the bytes b in the terminal. If filename=None the filename defaults to "Unnamed file". width and height are strings, following the format N: N chara...
python
def display_image_bytes(b, filename=None, inline=1, width='auto', height='auto', preserve_aspect_ratio=None): """ Display the image given by the bytes b in the terminal. If filename=None the filename defaults to "Unnamed file". width and height are strings, following the format N: N chara...
[ "def", "display_image_bytes", "(", "b", ",", "filename", "=", "None", ",", "inline", "=", "1", ",", "width", "=", "'auto'", ",", "height", "=", "'auto'", ",", "preserve_aspect_ratio", "=", "None", ")", ":", "sys", ".", "stdout", ".", "buffer", ".", "wr...
Display the image given by the bytes b in the terminal. If filename=None the filename defaults to "Unnamed file". width and height are strings, following the format N: N character cells. Npx: N pixels. N%: N percent of the session's width or height. 'auto': The image's inhe...
[ "Display", "the", "image", "given", "by", "the", "bytes", "b", "in", "the", "terminal", "." ]
train
https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/images.py#L56-L83
asmeurer/iterm2-tools
iterm2_tools/images.py
display_image_file
def display_image_file(fn, width='auto', height='auto', preserve_aspect_ratio=None): """ Display an image in the terminal. A newline is not printed. width and height are strings, following the format N: N character cells. Npx: N pixels. N%: N percent of the session's width o...
python
def display_image_file(fn, width='auto', height='auto', preserve_aspect_ratio=None): """ Display an image in the terminal. A newline is not printed. width and height are strings, following the format N: N character cells. Npx: N pixels. N%: N percent of the session's width o...
[ "def", "display_image_file", "(", "fn", ",", "width", "=", "'auto'", ",", "height", "=", "'auto'", ",", "preserve_aspect_ratio", "=", "None", ")", ":", "with", "open", "(", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "expanduser", ...
Display an image in the terminal. A newline is not printed. width and height are strings, following the format N: N character cells. Npx: N pixels. N%: N percent of the session's width or height. 'auto': The image's inherent size will be used to determine an appropriate ...
[ "Display", "an", "image", "in", "the", "terminal", "." ]
train
https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/images.py#L85-L112
xolox/python-qpass
setup.py
get_requirements
def get_requirements(*args): """Get requirements from pip requirement files.""" requirements = set() contents = get_contents(*args) for line in contents.splitlines(): # Strip comments. line = re.sub(r'^#.*|\s#.*', '', line) # Ignore empty lines if line and not line.isspac...
python
def get_requirements(*args): """Get requirements from pip requirement files.""" requirements = set() contents = get_contents(*args) for line in contents.splitlines(): # Strip comments. line = re.sub(r'^#.*|\s#.*', '', line) # Ignore empty lines if line and not line.isspac...
[ "def", "get_requirements", "(", "*", "args", ")", ":", "requirements", "=", "set", "(", ")", "contents", "=", "get_contents", "(", "*", "args", ")", "for", "line", "in", "contents", ".", "splitlines", "(", ")", ":", "# Strip comments.", "line", "=", "re"...
Get requirements from pip requirement files.
[ "Get", "requirements", "from", "pip", "requirement", "files", "." ]
train
https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/setup.py#L44-L54
ministryofjustice/govuk-bank-holidays
govuk_bank_holidays/bank_holidays.py
BankHolidays.get_holidays
def get_holidays(self, division=None, year=None): """ Gets a list of all known bank holidays, optionally filtered by division and/or year :param division: see division constants; defaults to common holidays :param year: defaults to all available years :return: list of dicts with ...
python
def get_holidays(self, division=None, year=None): """ Gets a list of all known bank holidays, optionally filtered by division and/or year :param division: see division constants; defaults to common holidays :param year: defaults to all available years :return: list of dicts with ...
[ "def", "get_holidays", "(", "self", ",", "division", "=", "None", ",", "year", "=", "None", ")", ":", "if", "division", ":", "holidays", "=", "self", ".", "data", "[", "division", "]", "else", ":", "holidays", "=", "self", ".", "data", "[", "self", ...
Gets a list of all known bank holidays, optionally filtered by division and/or year :param division: see division constants; defaults to common holidays :param year: defaults to all available years :return: list of dicts with titles, dates, etc
[ "Gets", "a", "list", "of", "all", "known", "bank", "holidays", "optionally", "filtered", "by", "division", "and", "/", "or", "year", ":", "param", "division", ":", "see", "division", "constants", ";", "defaults", "to", "common", "holidays", ":", "param", "...
train
https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L87-L106
ministryofjustice/govuk-bank-holidays
govuk_bank_holidays/bank_holidays.py
BankHolidays.get_next_holiday
def get_next_holiday(self, division=None, date=None): """ Returns the next known bank holiday :param division: see division constants; defaults to common holidays :param date: search starting from this date; defaults to today :return: dict """ date = date or datet...
python
def get_next_holiday(self, division=None, date=None): """ Returns the next known bank holiday :param division: see division constants; defaults to common holidays :param date: search starting from this date; defaults to today :return: dict """ date = date or datet...
[ "def", "get_next_holiday", "(", "self", ",", "division", "=", "None", ",", "date", "=", "None", ")", ":", "date", "=", "date", "or", "datetime", ".", "date", ".", "today", "(", ")", "for", "holiday", "in", "self", ".", "get_holidays", "(", "division", ...
Returns the next known bank holiday :param division: see division constants; defaults to common holidays :param date: search starting from this date; defaults to today :return: dict
[ "Returns", "the", "next", "known", "bank", "holiday", ":", "param", "division", ":", "see", "division", "constants", ";", "defaults", "to", "common", "holidays", ":", "param", "date", ":", "search", "starting", "from", "this", "date", ";", "defaults", "to", ...
train
https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L108-L118
ministryofjustice/govuk-bank-holidays
govuk_bank_holidays/bank_holidays.py
BankHolidays.is_holiday
def is_holiday(self, date, division=None): """ True if the date is a known bank holiday :param date: the date to check :param division: see division constants; defaults to common holidays :return: bool """ return date in (holiday['date'] for holiday in self.get_ho...
python
def is_holiday(self, date, division=None): """ True if the date is a known bank holiday :param date: the date to check :param division: see division constants; defaults to common holidays :return: bool """ return date in (holiday['date'] for holiday in self.get_ho...
[ "def", "is_holiday", "(", "self", ",", "date", ",", "division", "=", "None", ")", ":", "return", "date", "in", "(", "holiday", "[", "'date'", "]", "for", "holiday", "in", "self", ".", "get_holidays", "(", "division", "=", "division", ")", ")" ]
True if the date is a known bank holiday :param date: the date to check :param division: see division constants; defaults to common holidays :return: bool
[ "True", "if", "the", "date", "is", "a", "known", "bank", "holiday", ":", "param", "date", ":", "the", "date", "to", "check", ":", "param", "division", ":", "see", "division", "constants", ";", "defaults", "to", "common", "holidays", ":", "return", ":", ...
train
https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L120-L127
ministryofjustice/govuk-bank-holidays
govuk_bank_holidays/bank_holidays.py
BankHolidays.get_next_work_day
def get_next_work_day(self, division=None, date=None): """ Returns the next work day, skipping weekends and bank holidays :param division: see division constants; defaults to common holidays :param date: search starting from this date; defaults to today :return: datetime.date; NB...
python
def get_next_work_day(self, division=None, date=None): """ Returns the next work day, skipping weekends and bank holidays :param division: see division constants; defaults to common holidays :param date: search starting from this date; defaults to today :return: datetime.date; NB...
[ "def", "get_next_work_day", "(", "self", ",", "division", "=", "None", ",", "date", "=", "None", ")", ":", "date", "=", "date", "or", "datetime", ".", "date", ".", "today", "(", ")", "one_day", "=", "datetime", ".", "timedelta", "(", "days", "=", "1"...
Returns the next work day, skipping weekends and bank holidays :param division: see division constants; defaults to common holidays :param date: search starting from this date; defaults to today :return: datetime.date; NB: get_next_holiday returns a dict
[ "Returns", "the", "next", "work", "day", "skipping", "weekends", "and", "bank", "holidays", ":", "param", "division", ":", "see", "division", "constants", ";", "defaults", "to", "common", "holidays", ":", "param", "date", ":", "search", "starting", "from", "...
train
https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L129-L142
ministryofjustice/govuk-bank-holidays
govuk_bank_holidays/bank_holidays.py
BankHolidays.is_work_day
def is_work_day(self, date, division=None): """ True if the date is not a weekend or a known bank holiday :param date: the date to check :param division: see division constants; defaults to common holidays :return: bool """ return date.weekday() not in self.weeken...
python
def is_work_day(self, date, division=None): """ True if the date is not a weekend or a known bank holiday :param date: the date to check :param division: see division constants; defaults to common holidays :return: bool """ return date.weekday() not in self.weeken...
[ "def", "is_work_day", "(", "self", ",", "date", ",", "division", "=", "None", ")", ":", "return", "date", ".", "weekday", "(", ")", "not", "in", "self", ".", "weekend", "and", "date", "not", "in", "(", "holiday", "[", "'date'", "]", "for", "holiday",...
True if the date is not a weekend or a known bank holiday :param date: the date to check :param division: see division constants; defaults to common holidays :return: bool
[ "True", "if", "the", "date", "is", "not", "a", "weekend", "or", "a", "known", "bank", "holiday", ":", "param", "date", ":", "the", "date", "to", "check", ":", "param", "division", ":", "see", "division", "constants", ";", "defaults", "to", "common", "h...
train
https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L144-L153
blixt/py-starbound
starbound/__init__.py
World.get_all_regions_with_tiles
def get_all_regions_with_tiles(self): """ Generator which yields a set of (rx, ry) tuples which describe all regions for which the world has tile data """ for key in self.get_all_keys(): (layer, rx, ry) = struct.unpack('>BHH', key) if layer == 1: ...
python
def get_all_regions_with_tiles(self): """ Generator which yields a set of (rx, ry) tuples which describe all regions for which the world has tile data """ for key in self.get_all_keys(): (layer, rx, ry) = struct.unpack('>BHH', key) if layer == 1: ...
[ "def", "get_all_regions_with_tiles", "(", "self", ")", ":", "for", "key", "in", "self", ".", "get_all_keys", "(", ")", ":", "(", "layer", ",", "rx", ",", "ry", ")", "=", "struct", ".", "unpack", "(", "'>BHH'", ",", "key", ")", "if", "layer", "==", ...
Generator which yields a set of (rx, ry) tuples which describe all regions for which the world has tile data
[ "Generator", "which", "yields", "a", "set", "of", "(", "rx", "ry", ")", "tuples", "which", "describe", "all", "regions", "for", "which", "the", "world", "has", "tile", "data" ]
train
https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/__init__.py#L95-L103
blixt/py-starbound
starbound/__init__.py
World.get_entity_uuid_coords
def get_entity_uuid_coords(self, uuid): """ Returns the coordinates of the given entity UUID inside this world, or `None` if the UUID is not found. """ if uuid in self._entity_to_region_map: coords = self._entity_to_region_map[uuid] entities = self.get_ent...
python
def get_entity_uuid_coords(self, uuid): """ Returns the coordinates of the given entity UUID inside this world, or `None` if the UUID is not found. """ if uuid in self._entity_to_region_map: coords = self._entity_to_region_map[uuid] entities = self.get_ent...
[ "def", "get_entity_uuid_coords", "(", "self", ",", "uuid", ")", ":", "if", "uuid", "in", "self", ".", "_entity_to_region_map", ":", "coords", "=", "self", ".", "_entity_to_region_map", "[", "uuid", "]", "entities", "=", "self", ".", "get_entities", "(", "*",...
Returns the coordinates of the given entity UUID inside this world, or `None` if the UUID is not found.
[ "Returns", "the", "coordinates", "of", "the", "given", "entity", "UUID", "inside", "this", "world", "or", "None", "if", "the", "UUID", "is", "not", "found", "." ]
train
https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/__init__.py#L110-L121
blixt/py-starbound
starbound/__init__.py
World._entity_to_region_map
def _entity_to_region_map(self): """ A dict whose keys are the UUIDs (or just IDs, in some cases) of entities, and whose values are the `(rx, ry)` coordinates in which that entity can be found. This can be used to easily locate particular entities inside the world. """ ...
python
def _entity_to_region_map(self): """ A dict whose keys are the UUIDs (or just IDs, in some cases) of entities, and whose values are the `(rx, ry)` coordinates in which that entity can be found. This can be used to easily locate particular entities inside the world. """ ...
[ "def", "_entity_to_region_map", "(", "self", ")", ":", "entity_to_region", "=", "{", "}", "for", "key", "in", "self", ".", "get_all_keys", "(", ")", ":", "layer", ",", "rx", ",", "ry", "=", "struct", ".", "unpack", "(", "'>BHH'", ",", "key", ")", "if...
A dict whose keys are the UUIDs (or just IDs, in some cases) of entities, and whose values are the `(rx, ry)` coordinates in which that entity can be found. This can be used to easily locate particular entities inside the world.
[ "A", "dict", "whose", "keys", "are", "the", "UUIDs", "(", "or", "just", "IDs", "in", "some", "cases", ")", "of", "entities", "and", "whose", "values", "are", "the", "(", "rx", "ry", ")", "coordinates", "in", "which", "that", "entity", "can", "be", "f...
train
https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/__init__.py#L149-L168
xolox/python-qpass
qpass/__init__.py
create_fuzzy_pattern
def create_fuzzy_pattern(pattern): """ Convert a string into a fuzzy regular expression pattern. :param pattern: The input pattern (a string). :returns: A compiled regular expression object. This function works by adding ``.*`` between each of the characters in the input pattern and compiling ...
python
def create_fuzzy_pattern(pattern): """ Convert a string into a fuzzy regular expression pattern. :param pattern: The input pattern (a string). :returns: A compiled regular expression object. This function works by adding ``.*`` between each of the characters in the input pattern and compiling ...
[ "def", "create_fuzzy_pattern", "(", "pattern", ")", ":", "return", "re", ".", "compile", "(", "\".*\"", ".", "join", "(", "map", "(", "re", ".", "escape", ",", "pattern", ")", ")", ",", "re", ".", "IGNORECASE", ")" ]
Convert a string into a fuzzy regular expression pattern. :param pattern: The input pattern (a string). :returns: A compiled regular expression object. This function works by adding ``.*`` between each of the characters in the input pattern and compiling the resulting expression into a case insens...
[ "Convert", "a", "string", "into", "a", "fuzzy", "regular", "expression", "pattern", "." ]
train
https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L431-L442
xolox/python-qpass
qpass/__init__.py
AbstractPasswordStore.filtered_entries
def filtered_entries(self): """A list of :class:`PasswordEntry` objects that don't match the exclude list.""" return [ e for e in self.entries if not any(fnmatch.fnmatch(e.name.lower(), p.lower()) for p in self.exclude_list) ]
python
def filtered_entries(self): """A list of :class:`PasswordEntry` objects that don't match the exclude list.""" return [ e for e in self.entries if not any(fnmatch.fnmatch(e.name.lower(), p.lower()) for p in self.exclude_list) ]
[ "def", "filtered_entries", "(", "self", ")", ":", "return", "[", "e", "for", "e", "in", "self", ".", "entries", "if", "not", "any", "(", "fnmatch", ".", "fnmatch", "(", "e", ".", "name", ".", "lower", "(", ")", ",", "p", ".", "lower", "(", ")", ...
A list of :class:`PasswordEntry` objects that don't match the exclude list.
[ "A", "list", "of", ":", "class", ":", "PasswordEntry", "objects", "that", "don", "t", "match", "the", "exclude", "list", "." ]
train
https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L104-L108
xolox/python-qpass
qpass/__init__.py
AbstractPasswordStore.fuzzy_search
def fuzzy_search(self, *filters): """ Perform a "fuzzy" search that matches the given characters in the given order. :param filters: The pattern(s) to search for. :returns: The matched password names (a list of strings). """ matches = [] logger.verbose( ...
python
def fuzzy_search(self, *filters): """ Perform a "fuzzy" search that matches the given characters in the given order. :param filters: The pattern(s) to search for. :returns: The matched password names (a list of strings). """ matches = [] logger.verbose( ...
[ "def", "fuzzy_search", "(", "self", ",", "*", "filters", ")", ":", "matches", "=", "[", "]", "logger", ".", "verbose", "(", "\"Performing fuzzy search on %s (%s) ..\"", ",", "pluralize", "(", "len", "(", "filters", ")", ",", "\"pattern\"", ")", ",", "concate...
Perform a "fuzzy" search that matches the given characters in the given order. :param filters: The pattern(s) to search for. :returns: The matched password names (a list of strings).
[ "Perform", "a", "fuzzy", "search", "that", "matches", "the", "given", "characters", "in", "the", "given", "order", "." ]
train
https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L110-L130