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
hackerlist/glassdoor
glassdoor/gd.py
parse_suggestions
def parse_suggestions(soup): """Suggests similar/related companies to query""" selector_comps = {'class': 'companyData'} companies = soup.findAll('div', selector_comps) def is_exact_match(c): """Determines if this company suggestion has an [exact match] html label or whether its name ma...
python
def parse_suggestions(soup): """Suggests similar/related companies to query""" selector_comps = {'class': 'companyData'} companies = soup.findAll('div', selector_comps) def is_exact_match(c): """Determines if this company suggestion has an [exact match] html label or whether its name ma...
[ "def", "parse_suggestions", "(", "soup", ")", ":", "selector_comps", "=", "{", "'class'", ":", "'companyData'", "}", "companies", "=", "soup", ".", "findAll", "(", "'div'", ",", "selector_comps", ")", "def", "is_exact_match", "(", "c", ")", ":", "\"\"\"Deter...
Suggests similar/related companies to query
[ "Suggests", "similar", "/", "related", "companies", "to", "query" ]
train
https://github.com/hackerlist/glassdoor/blob/953bac53d499eca439ecd812892605d1906cb055/glassdoor/gd.py#L258-L289
hackerlist/glassdoor
glassdoor/gd.py
parse
def parse(soup): """Parses the results for a company search and return the results if is_direct_match. If no company is found, a list of suggestions are returned as dict. If one such recommendation is found to be an exact match, re-perform request for this exact match """ if is_direct_match(sou...
python
def parse(soup): """Parses the results for a company search and return the results if is_direct_match. If no company is found, a list of suggestions are returned as dict. If one such recommendation is found to be an exact match, re-perform request for this exact match """ if is_direct_match(sou...
[ "def", "parse", "(", "soup", ")", ":", "if", "is_direct_match", "(", "soup", ")", ":", "return", "{", "'satisfaction'", ":", "parse_satisfaction", "(", "soup", ")", ",", "'ceo'", ":", "parse_ceo", "(", "soup", ")", ",", "'meta'", ":", "parse_meta", "(", ...
Parses the results for a company search and return the results if is_direct_match. If no company is found, a list of suggestions are returned as dict. If one such recommendation is found to be an exact match, re-perform request for this exact match
[ "Parses", "the", "results", "for", "a", "company", "search", "and", "return", "the", "results", "if", "is_direct_match", ".", "If", "no", "company", "is", "found", "a", "list", "of", "suggestions", "are", "returned", "as", "dict", ".", "If", "one", "such",...
train
https://github.com/hackerlist/glassdoor/blob/953bac53d499eca439ecd812892605d1906cb055/glassdoor/gd.py#L291-L309
callsign-viper/Flask-GraphQL-Auth
flask_graphql_auth/main.py
GraphQLAuth.init_app
def init_app(self, app): """ Register this extension with the flask app. :param app: A flask application """ # Save this so we can use it later in the extension if not hasattr(app, 'extensions'): # pragma: no cover app.extensions = {} app.extensions[...
python
def init_app(self, app): """ Register this extension with the flask app. :param app: A flask application """ # Save this so we can use it later in the extension if not hasattr(app, 'extensions'): # pragma: no cover app.extensions = {} app.extensions[...
[ "def", "init_app", "(", "self", ",", "app", ")", ":", "# Save this so we can use it later in the extension", "if", "not", "hasattr", "(", "app", ",", "'extensions'", ")", ":", "# pragma: no cover", "app", ".", "extensions", "=", "{", "}", "app", ".", "extensions...
Register this extension with the flask app. :param app: A flask application
[ "Register", "this", "extension", "with", "the", "flask", "app", "." ]
train
https://github.com/callsign-viper/Flask-GraphQL-Auth/blob/27897a6ef81e12f87e9695fbaf6659ff025ae782/flask_graphql_auth/main.py#L28-L39
callsign-viper/Flask-GraphQL-Auth
flask_graphql_auth/main.py
GraphQLAuth._set_default__configuration_options
def _set_default__configuration_options(app): """ Sets the default configuration options used by this extension """ app.config.setdefault('JWT_TOKEN_ARGUMENT_NAME', "token") # Name of token argument in GraphQL request resolver app.config.setdefault('JWT_REFRESH_TOKEN_ARGUMENT_NA...
python
def _set_default__configuration_options(app): """ Sets the default configuration options used by this extension """ app.config.setdefault('JWT_TOKEN_ARGUMENT_NAME', "token") # Name of token argument in GraphQL request resolver app.config.setdefault('JWT_REFRESH_TOKEN_ARGUMENT_NA...
[ "def", "_set_default__configuration_options", "(", "app", ")", ":", "app", ".", "config", ".", "setdefault", "(", "'JWT_TOKEN_ARGUMENT_NAME'", ",", "\"token\"", ")", "# Name of token argument in GraphQL request resolver", "app", ".", "config", ".", "setdefault", "(", "'...
Sets the default configuration options used by this extension
[ "Sets", "the", "default", "configuration", "options", "used", "by", "this", "extension" ]
train
https://github.com/callsign-viper/Flask-GraphQL-Auth/blob/27897a6ef81e12f87e9695fbaf6659ff025ae782/flask_graphql_auth/main.py#L42-L55
callsign-viper/Flask-GraphQL-Auth
flask_graphql_auth/decorators.py
decode_jwt
def decode_jwt(encoded_token, secret, algorithm, identity_claim_key, user_claims_key): """ Decodes an encoded JWT :param encoded_token: The encoded JWT string to decode :param secret: Secret key used to encode the JWT :param algorithm: Algorithm used to encode the JWT :param iden...
python
def decode_jwt(encoded_token, secret, algorithm, identity_claim_key, user_claims_key): """ Decodes an encoded JWT :param encoded_token: The encoded JWT string to decode :param secret: Secret key used to encode the JWT :param algorithm: Algorithm used to encode the JWT :param iden...
[ "def", "decode_jwt", "(", "encoded_token", ",", "secret", ",", "algorithm", ",", "identity_claim_key", ",", "user_claims_key", ")", ":", "# This call verifies the ext, iat, and nbf claims", "data", "=", "jwt", ".", "decode", "(", "encoded_token", ",", "secret", ",", ...
Decodes an encoded JWT :param encoded_token: The encoded JWT string to decode :param secret: Secret key used to encode the JWT :param algorithm: Algorithm used to encode the JWT :param identity_claim_key: expected key that contains the identity :param user_claims_key: expected key that contains the...
[ "Decodes", "an", "encoded", "JWT" ]
train
https://github.com/callsign-viper/Flask-GraphQL-Auth/blob/27897a6ef81e12f87e9695fbaf6659ff025ae782/flask_graphql_auth/decorators.py#L9-L34
callsign-viper/Flask-GraphQL-Auth
flask_graphql_auth/decorators.py
get_jwt_data
def get_jwt_data(token, token_type): """ Decodes encoded JWT token by using extension setting and validates token type :param token: The encoded JWT string to decode :param token_type: JWT type for type validation (access or refresh) :return: Dictionary containing contents of the JWT """ jw...
python
def get_jwt_data(token, token_type): """ Decodes encoded JWT token by using extension setting and validates token type :param token: The encoded JWT string to decode :param token_type: JWT type for type validation (access or refresh) :return: Dictionary containing contents of the JWT """ jw...
[ "def", "get_jwt_data", "(", "token", ",", "token_type", ")", ":", "jwt_data", "=", "decode_jwt", "(", "encoded_token", "=", "token", ",", "secret", "=", "current_app", ".", "config", "[", "'JWT_SECRET_KEY'", "]", ",", "algorithm", "=", "'HS256'", ",", "ident...
Decodes encoded JWT token by using extension setting and validates token type :param token: The encoded JWT string to decode :param token_type: JWT type for type validation (access or refresh) :return: Dictionary containing contents of the JWT
[ "Decodes", "encoded", "JWT", "token", "by", "using", "extension", "setting", "and", "validates", "token", "type" ]
train
https://github.com/callsign-viper/Flask-GraphQL-Auth/blob/27897a6ef81e12f87e9695fbaf6659ff025ae782/flask_graphql_auth/decorators.py#L37-L57
callsign-viper/Flask-GraphQL-Auth
flask_graphql_auth/decorators.py
query_jwt_required
def query_jwt_required(fn): """ A decorator to protect a query resolver. If you decorate an resolver with this, it will ensure that the requester has a valid access token before allowing the resolver to be called. This does not check the freshness of the access token. """ @wraps(fn) def...
python
def query_jwt_required(fn): """ A decorator to protect a query resolver. If you decorate an resolver with this, it will ensure that the requester has a valid access token before allowing the resolver to be called. This does not check the freshness of the access token. """ @wraps(fn) def...
[ "def", "query_jwt_required", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "print", "(", "args", "[", "0", "]", ")", "token", "=", "kwargs", ".", "pop", "(", "current_app...
A decorator to protect a query resolver. If you decorate an resolver with this, it will ensure that the requester has a valid access token before allowing the resolver to be called. This does not check the freshness of the access token.
[ "A", "decorator", "to", "protect", "a", "query", "resolver", "." ]
train
https://github.com/callsign-viper/Flask-GraphQL-Auth/blob/27897a6ef81e12f87e9695fbaf6659ff025ae782/flask_graphql_auth/decorators.py#L82-L100
callsign-viper/Flask-GraphQL-Auth
flask_graphql_auth/decorators.py
mutation_jwt_required
def mutation_jwt_required(fn): """ A decorator to protect a mutation. If you decorate a mutation with this, it will ensure that the requester has a valid access token before allowing the mutation to be called. This does not check the freshness of the access token. """ @wraps(fn) def wra...
python
def mutation_jwt_required(fn): """ A decorator to protect a mutation. If you decorate a mutation with this, it will ensure that the requester has a valid access token before allowing the mutation to be called. This does not check the freshness of the access token. """ @wraps(fn) def wra...
[ "def", "mutation_jwt_required", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "wrapper", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "token", "=", "kwargs", ".", "pop", "(", "current_app", ".", "config", "[", "'JWT_...
A decorator to protect a mutation. If you decorate a mutation with this, it will ensure that the requester has a valid access token before allowing the mutation to be called. This does not check the freshness of the access token.
[ "A", "decorator", "to", "protect", "a", "mutation", "." ]
train
https://github.com/callsign-viper/Flask-GraphQL-Auth/blob/27897a6ef81e12f87e9695fbaf6659ff025ae782/flask_graphql_auth/decorators.py#L122-L139
callsign-viper/Flask-GraphQL-Auth
flask_graphql_auth/decorators.py
mutation_jwt_refresh_token_required
def mutation_jwt_refresh_token_required(fn): """ A decorator to protect a mutation. If you decorate anmutation with this, it will ensure that the requester has a valid refresh token before allowing the mutation to be called. """ @wraps(fn) def wrapper(cls, *args, **kwargs): token = ...
python
def mutation_jwt_refresh_token_required(fn): """ A decorator to protect a mutation. If you decorate anmutation with this, it will ensure that the requester has a valid refresh token before allowing the mutation to be called. """ @wraps(fn) def wrapper(cls, *args, **kwargs): token = ...
[ "def", "mutation_jwt_refresh_token_required", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "wrapper", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "token", "=", "kwargs", ".", "pop", "(", "current_app", ".", "config", ...
A decorator to protect a mutation. If you decorate anmutation with this, it will ensure that the requester has a valid refresh token before allowing the mutation to be called.
[ "A", "decorator", "to", "protect", "a", "mutation", "." ]
train
https://github.com/callsign-viper/Flask-GraphQL-Auth/blob/27897a6ef81e12f87e9695fbaf6659ff025ae782/flask_graphql_auth/decorators.py#L142-L158
ahtn/python-easyhid
easyhid/easyhid.py
_hid_enumerate
def _hid_enumerate(vendor_id=0, product_id=0): """ Enumerates all the hid devices for VID:PID. Returns a list of `HIDDevice` objects. If vid is 0, then match any vendor id. Similarly, if pid is 0, match any product id. If both are zero, enumerate all HID devices. """ start = hidapi.hid_enumerat...
python
def _hid_enumerate(vendor_id=0, product_id=0): """ Enumerates all the hid devices for VID:PID. Returns a list of `HIDDevice` objects. If vid is 0, then match any vendor id. Similarly, if pid is 0, match any product id. If both are zero, enumerate all HID devices. """ start = hidapi.hid_enumerat...
[ "def", "_hid_enumerate", "(", "vendor_id", "=", "0", ",", "product_id", "=", "0", ")", ":", "start", "=", "hidapi", ".", "hid_enumerate", "(", "vendor_id", ",", "product_id", ")", "result", "=", "[", "]", "cur", "=", "ffi", ".", "new", "(", "\"struct h...
Enumerates all the hid devices for VID:PID. Returns a list of `HIDDevice` objects. If vid is 0, then match any vendor id. Similarly, if pid is 0, match any product id. If both are zero, enumerate all HID devices.
[ "Enumerates", "all", "the", "hid", "devices", "for", "VID", ":", "PID", ".", "Returns", "a", "list", "of", "HIDDevice", "objects", ".", "If", "vid", "is", "0", "then", "match", "any", "vendor", "id", ".", "Similarly", "if", "pid", "is", "0", "match", ...
train
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L414-L433
ahtn/python-easyhid
easyhid/easyhid.py
HIDDevice.open
def open(self): """ Open the HID device for reading and writing. """ if self._is_open: raise HIDException("Failed to open device: HIDDevice already open") path = self.path.encode('utf-8') dev = hidapi.hid_open_path(path) if dev: self._is_...
python
def open(self): """ Open the HID device for reading and writing. """ if self._is_open: raise HIDException("Failed to open device: HIDDevice already open") path = self.path.encode('utf-8') dev = hidapi.hid_open_path(path) if dev: self._is_...
[ "def", "open", "(", "self", ")", ":", "if", "self", ".", "_is_open", ":", "raise", "HIDException", "(", "\"Failed to open device: HIDDevice already open\"", ")", "path", "=", "self", ".", "path", ".", "encode", "(", "'utf-8'", ")", "dev", "=", "hidapi", ".",...
Open the HID device for reading and writing.
[ "Open", "the", "HID", "device", "for", "reading", "and", "writing", "." ]
train
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L112-L126
ahtn/python-easyhid
easyhid/easyhid.py
HIDDevice.close
def close(self): """ Closes the hid device """ if self._is_open: self._is_open = False hidapi.hid_close(self._device)
python
def close(self): """ Closes the hid device """ if self._is_open: self._is_open = False hidapi.hid_close(self._device)
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_is_open", ":", "self", ".", "_is_open", "=", "False", "hidapi", ".", "hid_close", "(", "self", ".", "_device", ")" ]
Closes the hid device
[ "Closes", "the", "hid", "device" ]
train
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L129-L135
ahtn/python-easyhid
easyhid/easyhid.py
HIDDevice.write
def write(self, data, report_id=0): """ Writes data to the HID device on its endpoint. Parameters: data: data to send on the HID endpoint report_id: the report ID to use. Returns: The number of bytes written including the report ID. """ ...
python
def write(self, data, report_id=0): """ Writes data to the HID device on its endpoint. Parameters: data: data to send on the HID endpoint report_id: the report ID to use. Returns: The number of bytes written including the report ID. """ ...
[ "def", "write", "(", "self", ",", "data", ",", "report_id", "=", "0", ")", ":", "if", "not", "self", ".", "_is_open", ":", "raise", "HIDException", "(", "\"HIDDevice not open\"", ")", "write_data", "=", "bytearray", "(", "[", "report_id", "]", ")", "+", ...
Writes data to the HID device on its endpoint. Parameters: data: data to send on the HID endpoint report_id: the report ID to use. Returns: The number of bytes written including the report ID.
[ "Writes", "data", "to", "the", "HID", "device", "on", "its", "endpoint", "." ]
train
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L137-L158
ahtn/python-easyhid
easyhid/easyhid.py
HIDDevice.read
def read(self, size=64, timeout=None): """ Read from the hid device on its endpoint. Parameters: size: number of bytes to read timeout: length to wait in milliseconds Returns: The HID report read from the device. The first byte in the result ...
python
def read(self, size=64, timeout=None): """ Read from the hid device on its endpoint. Parameters: size: number of bytes to read timeout: length to wait in milliseconds Returns: The HID report read from the device. The first byte in the result ...
[ "def", "read", "(", "self", ",", "size", "=", "64", ",", "timeout", "=", "None", ")", ":", "if", "not", "self", ".", "_is_open", ":", "raise", "HIDException", "(", "\"HIDDevice not open\"", ")", "data", "=", "[", "0", "]", "*", "size", "cdata", "=", ...
Read from the hid device on its endpoint. Parameters: size: number of bytes to read timeout: length to wait in milliseconds Returns: The HID report read from the device. The first byte in the result will be the report ID if used.
[ "Read", "from", "the", "hid", "device", "on", "its", "endpoint", "." ]
train
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L160-L192
ahtn/python-easyhid
easyhid/easyhid.py
HIDDevice.is_connected
def is_connected(self): """ Checks if the USB device is still connected """ if self._is_open: err = hidapi.hid_read_timeout(self._device, ffi.NULL, 0, 0) if err == -1: return False else: return True else: ...
python
def is_connected(self): """ Checks if the USB device is still connected """ if self._is_open: err = hidapi.hid_read_timeout(self._device, ffi.NULL, 0, 0) if err == -1: return False else: return True else: ...
[ "def", "is_connected", "(", "self", ")", ":", "if", "self", ".", "_is_open", ":", "err", "=", "hidapi", ".", "hid_read_timeout", "(", "self", ".", "_device", ",", "ffi", ".", "NULL", ",", "0", ",", "0", ")", "if", "err", "==", "-", "1", ":", "ret...
Checks if the USB device is still connected
[ "Checks", "if", "the", "USB", "device", "is", "still", "connected" ]
train
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L206-L221
ahtn/python-easyhid
easyhid/easyhid.py
HIDDevice.send_feature_report
def send_feature_report(self, data, report_id=0x00): """ Send a Feature report to a HID device. Feature reports are sent over the Control endpoint as a Set_Report transfer. Parameters: data The data to send Returns: This function returns the ...
python
def send_feature_report(self, data, report_id=0x00): """ Send a Feature report to a HID device. Feature reports are sent over the Control endpoint as a Set_Report transfer. Parameters: data The data to send Returns: This function returns the ...
[ "def", "send_feature_report", "(", "self", ",", "data", ",", "report_id", "=", "0x00", ")", ":", "if", "not", "self", ".", "_is_open", ":", "raise", "HIDException", "(", "\"HIDDevice not open\"", ")", "report", "=", "bytearray", "(", "[", "report_id", "]", ...
Send a Feature report to a HID device. Feature reports are sent over the Control endpoint as a Set_Report transfer. Parameters: data The data to send Returns: This function returns the actual number of bytes written
[ "Send", "a", "Feature", "report", "to", "a", "HID", "device", "." ]
train
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L223-L246
ahtn/python-easyhid
easyhid/easyhid.py
HIDDevice.get_feature_report
def get_feature_report(self, size, report_id=0x00): """ Get a feature report from a HID device. Feature reports are sent over the Control endpoint as a Get_Report transfer. Parameters: size The number of bytes to read. report_id The report id to...
python
def get_feature_report(self, size, report_id=0x00): """ Get a feature report from a HID device. Feature reports are sent over the Control endpoint as a Get_Report transfer. Parameters: size The number of bytes to read. report_id The report id to...
[ "def", "get_feature_report", "(", "self", ",", "size", ",", "report_id", "=", "0x00", ")", ":", "data", "=", "[", "0", "]", "*", "(", "size", "+", "1", ")", "cdata", "=", "ffi", ".", "new", "(", "\"unsigned char[]\"", ",", "bytes", "(", "data", ")"...
Get a feature report from a HID device. Feature reports are sent over the Control endpoint as a Get_Report transfer. Parameters: size The number of bytes to read. report_id The report id to read Returns: They bytes read from the HID report
[ "Get", "a", "feature", "report", "from", "a", "HID", "device", "." ]
train
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L248-L271
ahtn/python-easyhid
easyhid/easyhid.py
HIDDevice.get_error
def get_error(self): """ Get an error string from the device """ err_str = hidapi.hid_error(self._device) if err_str == ffi.NULL: return None else: return ffi.string(err_str)
python
def get_error(self): """ Get an error string from the device """ err_str = hidapi.hid_error(self._device) if err_str == ffi.NULL: return None else: return ffi.string(err_str)
[ "def", "get_error", "(", "self", ")", ":", "err_str", "=", "hidapi", ".", "hid_error", "(", "self", ".", "_device", ")", "if", "err_str", "==", "ffi", ".", "NULL", ":", "return", "None", "else", ":", "return", "ffi", ".", "string", "(", "err_str", ")...
Get an error string from the device
[ "Get", "an", "error", "string", "from", "the", "device" ]
train
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L273-L281
ahtn/python-easyhid
easyhid/easyhid.py
HIDDevice.get_indexed_string
def get_indexed_string(self, index): """ Get the string with the given index from the device """ max_len = 128 str_buf = ffi.new("wchar_t[]", str(bytearray(max_len))) ret = hidapi.hid_get_indexed_string(self._device, index, str_buf, max_len) if ret < 0: ...
python
def get_indexed_string(self, index): """ Get the string with the given index from the device """ max_len = 128 str_buf = ffi.new("wchar_t[]", str(bytearray(max_len))) ret = hidapi.hid_get_indexed_string(self._device, index, str_buf, max_len) if ret < 0: ...
[ "def", "get_indexed_string", "(", "self", ",", "index", ")", ":", "max_len", "=", "128", "str_buf", "=", "ffi", ".", "new", "(", "\"wchar_t[]\"", ",", "str", "(", "bytearray", "(", "max_len", ")", ")", ")", "ret", "=", "hidapi", ".", "hid_get_indexed_str...
Get the string with the given index from the device
[ "Get", "the", "string", "with", "the", "given", "index", "from", "the", "device" ]
train
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L313-L326
ahtn/python-easyhid
easyhid/easyhid.py
HIDDevice.description
def description(self): """ Get a string describing the HID descriptor. """ return \ """HIDDevice: {} | {:x}:{:x} | {} | {} | {} release_number: {} usage_page: {} usage: {} interface_number: {}\ """.format(self.path, self.vendor_id, self.product_i...
python
def description(self): """ Get a string describing the HID descriptor. """ return \ """HIDDevice: {} | {:x}:{:x} | {} | {} | {} release_number: {} usage_page: {} usage: {} interface_number: {}\ """.format(self.path, self.vendor_id, self.product_i...
[ "def", "description", "(", "self", ")", ":", "return", "\"\"\"HIDDevice:\n {} | {:x}:{:x} | {} | {} | {}\n release_number: {}\n usage_page: {}\n usage: {}\n interface_number: {}\\\n\"\"\"", ".", "format", "(", "self", ".", "path", ",", "self", ".", "vendor_id", ","...
Get a string describing the HID descriptor.
[ "Get", "a", "string", "describing", "the", "HID", "descriptor", "." ]
train
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L329-L350
ahtn/python-easyhid
easyhid/easyhid.py
Enumeration.find
def find(self, vid=None, pid=None, serial=None, interface=None, \ path=None, release_number=None, manufacturer=None, product=None, usage=None, usage_page=None): """ Attempts to open a device in this `Enumeration` object. Optional arguments can be provided to filter the re...
python
def find(self, vid=None, pid=None, serial=None, interface=None, \ path=None, release_number=None, manufacturer=None, product=None, usage=None, usage_page=None): """ Attempts to open a device in this `Enumeration` object. Optional arguments can be provided to filter the re...
[ "def", "find", "(", "self", ",", "vid", "=", "None", ",", "pid", "=", "None", ",", "serial", "=", "None", ",", "interface", "=", "None", ",", "path", "=", "None", ",", "release_number", "=", "None", ",", "manufacturer", "=", "None", ",", "product", ...
Attempts to open a device in this `Enumeration` object. Optional arguments can be provided to filter the resulting list based on various parameters of the HID devices. Args: vid: filters by USB Vendor ID pid: filters by USB Product ID serial: filters by USB s...
[ "Attempts", "to", "open", "a", "device", "in", "this", "Enumeration", "object", ".", "Optional", "arguments", "can", "be", "provided", "to", "filter", "the", "resulting", "list", "based", "on", "various", "parameters", "of", "the", "HID", "devices", "." ]
train
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L367-L411
sleepyfran/itunespy
itunespy/music_album.py
MusicAlbum.get_tracks
def get_tracks(self): """ Retrieves all the tracks of the album if they haven't been retrieved yet :return: List. Tracks of the current album """ if not self._track_list: tracks = itunespy.lookup(id=self.collection_id, entity=itunespy.entities['song'])[1:] ...
python
def get_tracks(self): """ Retrieves all the tracks of the album if they haven't been retrieved yet :return: List. Tracks of the current album """ if not self._track_list: tracks = itunespy.lookup(id=self.collection_id, entity=itunespy.entities['song'])[1:] ...
[ "def", "get_tracks", "(", "self", ")", ":", "if", "not", "self", ".", "_track_list", ":", "tracks", "=", "itunespy", ".", "lookup", "(", "id", "=", "self", ".", "collection_id", ",", "entity", "=", "itunespy", ".", "entities", "[", "'song'", "]", ")", ...
Retrieves all the tracks of the album if they haven't been retrieved yet :return: List. Tracks of the current album
[ "Retrieves", "all", "the", "tracks", "of", "the", "album", "if", "they", "haven", "t", "been", "retrieved", "yet", ":", "return", ":", "List", ".", "Tracks", "of", "the", "current", "album" ]
train
https://github.com/sleepyfran/itunespy/blob/0e7e931b135b5e0daae49ba68e9167ff4ac73eb5/itunespy/music_album.py#L31-L40
sleepyfran/itunespy
itunespy/music_album.py
MusicAlbum.get_album_time
def get_album_time(self, round_number=2): """ Retrieves all of the track's length and returns the sum of all :param round_number: Int. Number of decimals to round the sum :return: Int. Sum of all the track's length """ if not self._track_list: self.get_tracks(...
python
def get_album_time(self, round_number=2): """ Retrieves all of the track's length and returns the sum of all :param round_number: Int. Number of decimals to round the sum :return: Int. Sum of all the track's length """ if not self._track_list: self.get_tracks(...
[ "def", "get_album_time", "(", "self", ",", "round_number", "=", "2", ")", ":", "if", "not", "self", ".", "_track_list", ":", "self", ".", "get_tracks", "(", ")", "if", "self", ".", "_album_time", "is", "None", ":", "album_time", "=", "0.0", "for", "tra...
Retrieves all of the track's length and returns the sum of all :param round_number: Int. Number of decimals to round the sum :return: Int. Sum of all the track's length
[ "Retrieves", "all", "of", "the", "track", "s", "length", "and", "returns", "the", "sum", "of", "all", ":", "param", "round_number", ":", "Int", ".", "Number", "of", "decimals", "to", "round", "the", "sum", ":", "return", ":", "Int", ".", "Sum", "of", ...
train
https://github.com/sleepyfran/itunespy/blob/0e7e931b135b5e0daae49ba68e9167ff4ac73eb5/itunespy/music_album.py#L42-L55
sleepyfran/itunespy
itunespy/movie_artist.py
MovieArtist.get_movies
def get_movies(self): """ Retrieves all the movies published by the artist :return: List. Movies published by the artist """ return itunespy.lookup(id=self.artist_id, entity=itunespy.entities['movie'])[1:]
python
def get_movies(self): """ Retrieves all the movies published by the artist :return: List. Movies published by the artist """ return itunespy.lookup(id=self.artist_id, entity=itunespy.entities['movie'])[1:]
[ "def", "get_movies", "(", "self", ")", ":", "return", "itunespy", ".", "lookup", "(", "id", "=", "self", ".", "artist_id", ",", "entity", "=", "itunespy", ".", "entities", "[", "'movie'", "]", ")", "[", "1", ":", "]" ]
Retrieves all the movies published by the artist :return: List. Movies published by the artist
[ "Retrieves", "all", "the", "movies", "published", "by", "the", "artist", ":", "return", ":", "List", ".", "Movies", "published", "by", "the", "artist" ]
train
https://github.com/sleepyfran/itunespy/blob/0e7e931b135b5e0daae49ba68e9167ff4ac73eb5/itunespy/movie_artist.py#L29-L34
ladybug-tools/uwg
uwg/solarcalcs.py
SolarCalcs.solarcalcs
def solarcalcs(self): """ Solar Calculation Mutates RSM, BEM, and UCM objects based on following parameters: UCM # Urban Canopy - Building Energy Model object BEM # Building Energy Model object simTime # Simulation time bbject RSM ...
python
def solarcalcs(self): """ Solar Calculation Mutates RSM, BEM, and UCM objects based on following parameters: UCM # Urban Canopy - Building Energy Model object BEM # Building Energy Model object simTime # Simulation time bbject RSM ...
[ "def", "solarcalcs", "(", "self", ")", ":", "self", ".", "dir", "=", "self", ".", "forc", ".", "dir", "# Direct sunlight (perpendicular to the sun's ray)", "self", ".", "dif", "=", "self", ".", "forc", ".", "dif", "# Diffuse sunlight", "if", "self", ".", "di...
Solar Calculation Mutates RSM, BEM, and UCM objects based on following parameters: UCM # Urban Canopy - Building Energy Model object BEM # Building Energy Model object simTime # Simulation time bbject RSM # Rural Site & Vertical Diffusi...
[ "Solar", "Calculation", "Mutates", "RSM", "BEM", "and", "UCM", "objects", "based", "on", "following", "parameters", ":", "UCM", "#", "Urban", "Canopy", "-", "Building", "Energy", "Model", "object", "BEM", "#", "Building", "Energy", "Model", "object", "simTime"...
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/solarcalcs.py#L43-L140
ladybug-tools/uwg
uwg/solarcalcs.py
SolarCalcs.solarangles
def solarangles (self): """ Calculation based on NOAA. Solves for zenith angle, tangent of zenithal angle, and critical canyon angle based on following parameters: canAspect # aspect Ratio of canyon simTime # simulation parameters RSM.lon ...
python
def solarangles (self): """ Calculation based on NOAA. Solves for zenith angle, tangent of zenithal angle, and critical canyon angle based on following parameters: canAspect # aspect Ratio of canyon simTime # simulation parameters RSM.lon ...
[ "def", "solarangles", "(", "self", ")", ":", "ln", "=", "self", ".", "RSM", ".", "lon", "month", "=", "self", ".", "simTime", ".", "month", "day", "=", "self", ".", "simTime", ".", "day", "secDay", "=", "self", ".", "simTime", ".", "secDay", "# Tot...
Calculation based on NOAA. Solves for zenith angle, tangent of zenithal angle, and critical canyon angle based on following parameters: canAspect # aspect Ratio of canyon simTime # simulation parameters RSM.lon # longitude (deg) RSM.lat ...
[ "Calculation", "based", "on", "NOAA", ".", "Solves", "for", "zenith", "angle", "tangent", "of", "zenithal", "angle", "and", "critical", "canyon", "angle", "based", "on", "following", "parameters", ":", "canAspect", "#", "aspect", "Ratio", "of", "canyon", "simT...
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/solarcalcs.py#L142-L220
ladybug-tools/uwg
uwg/psychrometrics.py
psychrometrics
def psychrometrics (Tdb_in, w_in, P): """ Modified version of Psychometrics by Tea Zakula MIT Building Technology Lab Input: Tdb_in, w_in, P Output: Tdb, w, phi, h, Tdp, v where: Tdb_in = [K] dry bulb temperature w_in = [kgv/kgda] Humidity Ratio P = [P] Atmospheric Station Pressure ...
python
def psychrometrics (Tdb_in, w_in, P): """ Modified version of Psychometrics by Tea Zakula MIT Building Technology Lab Input: Tdb_in, w_in, P Output: Tdb, w, phi, h, Tdp, v where: Tdb_in = [K] dry bulb temperature w_in = [kgv/kgda] Humidity Ratio P = [P] Atmospheric Station Pressure ...
[ "def", "psychrometrics", "(", "Tdb_in", ",", "w_in", ",", "P", ")", ":", "# Change units", "c_air", "=", "1006.", "# [J/kg] air heat capacity, value from ASHRAE Fundamentals", "hlg", "=", "2501000.", "# [J/kg] latent heat, value from ASHRAE Fundamentals", "cw", "=", "1860."...
Modified version of Psychometrics by Tea Zakula MIT Building Technology Lab Input: Tdb_in, w_in, P Output: Tdb, w, phi, h, Tdp, v where: Tdb_in = [K] dry bulb temperature w_in = [kgv/kgda] Humidity Ratio P = [P] Atmospheric Station Pressure Tdb: [C] dry bulb temperature w: [kgv/kgd...
[ "Modified", "version", "of", "Psychometrics", "by", "Tea", "Zakula", "MIT", "Building", "Technology", "Lab", "Input", ":", "Tdb_in", "w_in", "P", "Output", ":", "Tdb", "w", "phi", "h", "Tdp", "v" ]
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/psychrometrics.py#L6-L51
sleepyfran/itunespy
itunespy/__init__.py
search
def search(term, country='US', media='all', entity=None, attribute=None, limit=50): """ Returns the result of the search of the specified term in an array of result_item(s) :param term: String. The URL-encoded text string you want to search for. Example: Steven Wilson. The method will take ...
python
def search(term, country='US', media='all', entity=None, attribute=None, limit=50): """ Returns the result of the search of the specified term in an array of result_item(s) :param term: String. The URL-encoded text string you want to search for. Example: Steven Wilson. The method will take ...
[ "def", "search", "(", "term", ",", "country", "=", "'US'", ",", "media", "=", "'all'", ",", "entity", "=", "None", ",", "attribute", "=", "None", ",", "limit", "=", "50", ")", ":", "search_url", "=", "_url_search_builder", "(", "term", ",", "country", ...
Returns the result of the search of the specified term in an array of result_item(s) :param term: String. The URL-encoded text string you want to search for. Example: Steven Wilson. The method will take care of spaces so you don't have to. :param country: String. The two-letter country code for...
[ "Returns", "the", "result", "of", "the", "search", "of", "the", "specified", "term", "in", "an", "array", "of", "result_item", "(", "s", ")", ":", "param", "term", ":", "String", ".", "The", "URL", "-", "encoded", "text", "string", "you", "want", "to",...
train
https://github.com/sleepyfran/itunespy/blob/0e7e931b135b5e0daae49ba68e9167ff4ac73eb5/itunespy/__init__.py#L32-L58
sleepyfran/itunespy
itunespy/__init__.py
lookup
def lookup(id=None, artist_amg_id=None, upc=None, country='US', media='all', entity=None, attribute=None, limit=50): """ Returns the result of the lookup of the specified id, artist_amg_id or upc in an array of result_item(s) :param id: String. iTunes ID of the artist, album, track, ebook or software :p...
python
def lookup(id=None, artist_amg_id=None, upc=None, country='US', media='all', entity=None, attribute=None, limit=50): """ Returns the result of the lookup of the specified id, artist_amg_id or upc in an array of result_item(s) :param id: String. iTunes ID of the artist, album, track, ebook or software :p...
[ "def", "lookup", "(", "id", "=", "None", ",", "artist_amg_id", "=", "None", ",", "upc", "=", "None", ",", "country", "=", "'US'", ",", "media", "=", "'all'", ",", "entity", "=", "None", ",", "attribute", "=", "None", ",", "limit", "=", "50", ")", ...
Returns the result of the lookup of the specified id, artist_amg_id or upc in an array of result_item(s) :param id: String. iTunes ID of the artist, album, track, ebook or software :param artist_amg_id: String. All Music Guide ID of the artist :param upc: String. UPCs/EANs :param country: String. The tw...
[ "Returns", "the", "result", "of", "the", "lookup", "of", "the", "specified", "id", "artist_amg_id", "or", "upc", "in", "an", "array", "of", "result_item", "(", "s", ")", ":", "param", "id", ":", "String", ".", "iTunes", "ID", "of", "the", "artist", "al...
train
https://github.com/sleepyfran/itunespy/blob/0e7e931b135b5e0daae49ba68e9167ff4ac73eb5/itunespy/__init__.py#L63-L94
sleepyfran/itunespy
itunespy/__init__.py
_get_result_list
def _get_result_list(json): """ Analyzes the provided JSON data and returns an array of result_item(s) based on its content :param json: Raw JSON data to analyze :return: An array of result_item(s) from the provided JSON data """ result_list = [] for item in json: if 'wrapperType' i...
python
def _get_result_list(json): """ Analyzes the provided JSON data and returns an array of result_item(s) based on its content :param json: Raw JSON data to analyze :return: An array of result_item(s) from the provided JSON data """ result_list = [] for item in json: if 'wrapperType' i...
[ "def", "_get_result_list", "(", "json", ")", ":", "result_list", "=", "[", "]", "for", "item", "in", "json", ":", "if", "'wrapperType'", "in", "item", ":", "# Music", "if", "item", "[", "'wrapperType'", "]", "==", "'artist'", "and", "item", "[", "'artist...
Analyzes the provided JSON data and returns an array of result_item(s) based on its content :param json: Raw JSON data to analyze :return: An array of result_item(s) from the provided JSON data
[ "Analyzes", "the", "provided", "JSON", "data", "and", "returns", "an", "array", "of", "result_item", "(", "s", ")", "based", "on", "its", "content", ":", "param", "json", ":", "Raw", "JSON", "data", "to", "analyze", ":", "return", ":", "An", "array", "...
train
https://github.com/sleepyfran/itunespy/blob/0e7e931b135b5e0daae49ba68e9167ff4ac73eb5/itunespy/__init__.py#L214-L270
sleepyfran/itunespy
itunespy/__init__.py
_url_search_builder
def _url_search_builder(term, country='US', media='all', entity=None, attribute=None, limit=50): """ Builds the URL to perform the search based on the provided data :param term: String. The URL-encoded text string you want to search for. Example: Steven Wilson. The method will take care of ...
python
def _url_search_builder(term, country='US', media='all', entity=None, attribute=None, limit=50): """ Builds the URL to perform the search based on the provided data :param term: String. The URL-encoded text string you want to search for. Example: Steven Wilson. The method will take care of ...
[ "def", "_url_search_builder", "(", "term", ",", "country", "=", "'US'", ",", "media", "=", "'all'", ",", "entity", "=", "None", ",", "attribute", "=", "None", ",", "limit", "=", "50", ")", ":", "built_url", "=", "base_search_url", "+", "_parse_query", "(...
Builds the URL to perform the search based on the provided data :param term: String. The URL-encoded text string you want to search for. Example: Steven Wilson. The method will take care of spaces so you don't have to. :param country: String. The two-letter country code for the store you want t...
[ "Builds", "the", "URL", "to", "perform", "the", "search", "based", "on", "the", "provided", "data", ":", "param", "term", ":", "String", ".", "The", "URL", "-", "encoded", "text", "string", "you", "want", "to", "search", "for", ".", "Example", ":", "St...
train
https://github.com/sleepyfran/itunespy/blob/0e7e931b135b5e0daae49ba68e9167ff4ac73eb5/itunespy/__init__.py#L273-L299
sleepyfran/itunespy
itunespy/__init__.py
_url_lookup_builder
def _url_lookup_builder(id=None, artist_amg_id=None, upc=None, country='US', media='music', entity=None, attribute=None, limit=50): """ Builds the URL to perform the lookup based on the provided data :param id: String. iTunes ID of the artist, album, track, ebook or software :par...
python
def _url_lookup_builder(id=None, artist_amg_id=None, upc=None, country='US', media='music', entity=None, attribute=None, limit=50): """ Builds the URL to perform the lookup based on the provided data :param id: String. iTunes ID of the artist, album, track, ebook or software :par...
[ "def", "_url_lookup_builder", "(", "id", "=", "None", ",", "artist_amg_id", "=", "None", ",", "upc", "=", "None", ",", "country", "=", "'US'", ",", "media", "=", "'music'", ",", "entity", "=", "None", ",", "attribute", "=", "None", ",", "limit", "=", ...
Builds the URL to perform the lookup based on the provided data :param id: String. iTunes ID of the artist, album, track, ebook or software :param artist_amg_id: String. All Music Guide ID of the artist :param upc: String. UPCs/EANs :param country: String. The two-letter country code for the store you w...
[ "Builds", "the", "URL", "to", "perform", "the", "lookup", "based", "on", "the", "provided", "data", ":", "param", "id", ":", "String", ".", "iTunes", "ID", "of", "the", "artist", "album", "track", "ebook", "or", "software", ":", "param", "artist_amg_id", ...
train
https://github.com/sleepyfran/itunespy/blob/0e7e931b135b5e0daae49ba68e9167ff4ac73eb5/itunespy/__init__.py#L302-L349
sleepyfran/itunespy
itunespy/music_artist.py
MusicArtist.get_albums
def get_albums(self): """ Retrieves all the albums by the artist :return: List. Albums published by the artist """ return itunespy.lookup(id=self.artist_id, entity=itunespy.entities['album'])[1:]
python
def get_albums(self): """ Retrieves all the albums by the artist :return: List. Albums published by the artist """ return itunespy.lookup(id=self.artist_id, entity=itunespy.entities['album'])[1:]
[ "def", "get_albums", "(", "self", ")", ":", "return", "itunespy", ".", "lookup", "(", "id", "=", "self", ".", "artist_id", ",", "entity", "=", "itunespy", ".", "entities", "[", "'album'", "]", ")", "[", "1", ":", "]" ]
Retrieves all the albums by the artist :return: List. Albums published by the artist
[ "Retrieves", "all", "the", "albums", "by", "the", "artist", ":", "return", ":", "List", ".", "Albums", "published", "by", "the", "artist" ]
train
https://github.com/sleepyfran/itunespy/blob/0e7e931b135b5e0daae49ba68e9167ff4ac73eb5/itunespy/music_artist.py#L29-L34
ladybug-tools/uwg
uwg/utilities.py
str2fl
def str2fl(x): """Recurses through lists and converts lists of string to float Args: x: string or list of strings """ def helper_to_fl(s_): """ deals with odd string imports converts to float""" if s_ == "": return "null" elif "," in s_: s_ = s_.r...
python
def str2fl(x): """Recurses through lists and converts lists of string to float Args: x: string or list of strings """ def helper_to_fl(s_): """ deals with odd string imports converts to float""" if s_ == "": return "null" elif "," in s_: s_ = s_.r...
[ "def", "str2fl", "(", "x", ")", ":", "def", "helper_to_fl", "(", "s_", ")", ":", "\"\"\" deals with odd string imports converts to float\"\"\"", "if", "s_", "==", "\"\"", ":", "return", "\"null\"", "elif", "\",\"", "in", "s_", ":", "s_", "=", "s_", ".", "rep...
Recurses through lists and converts lists of string to float Args: x: string or list of strings
[ "Recurses", "through", "lists", "and", "converts", "lists", "of", "string", "to", "float" ]
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/utilities.py#L42-L70
ladybug-tools/uwg
uwg/uwg.py
procMat
def procMat(materials, max_thickness, min_thickness): """ Processes material layer so that a material with single layer thickness is divided into two and material layer that is too thick is subdivided """ newmat = [] newthickness = [] k = materials.layerThermalCond Vhc = material...
python
def procMat(materials, max_thickness, min_thickness): """ Processes material layer so that a material with single layer thickness is divided into two and material layer that is too thick is subdivided """ newmat = [] newthickness = [] k = materials.layerThermalCond Vhc = material...
[ "def", "procMat", "(", "materials", ",", "max_thickness", ",", "min_thickness", ")", ":", "newmat", "=", "[", "]", "newthickness", "=", "[", "]", "k", "=", "materials", ".", "layerThermalCond", "Vhc", "=", "materials", ".", "layerVolHeat", "if", "len", "("...
Processes material layer so that a material with single layer thickness is divided into two and material layer that is too thick is subdivided
[ "Processes", "material", "layer", "so", "that", "a", "material", "with", "single", "layer", "thickness", "is", "divided", "into", "two", "and", "material", "layer", "that", "is", "too", "thick", "is", "subdivided" ]
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/uwg.py#L977-L1024
ladybug-tools/uwg
uwg/uwg.py
uwg.read_epw
def read_epw(self): """Section 2 - Read EPW file properties: self.climateDataPath self.newPathName self._header # header data self.epwinput # timestep data for weather self.lat # latitude self.lon # longit...
python
def read_epw(self): """Section 2 - Read EPW file properties: self.climateDataPath self.newPathName self._header # header data self.epwinput # timestep data for weather self.lat # latitude self.lon # longit...
[ "def", "read_epw", "(", "self", ")", ":", "# Make dir path to epw file\r", "self", ".", "climateDataPath", "=", "os", ".", "path", ".", "join", "(", "self", ".", "epwDir", ",", "self", ".", "epwFileName", ")", "# Open epw file and feed csv data to climate_data\r", ...
Section 2 - Read EPW file properties: self.climateDataPath self.newPathName self._header # header data self.epwinput # timestep data for weather self.lat # latitude self.lon # longitude self.GMT ...
[ "Section", "2", "-", "Read", "EPW", "file", "properties", ":", "self", ".", "climateDataPath", "self", ".", "newPathName", "self", ".", "_header", "#", "header", "data", "self", ".", "epwinput", "#", "timestep", "data", "for", "weather", "self", ".", "lat"...
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/uwg.py#L246-L297
ladybug-tools/uwg
uwg/uwg.py
uwg.read_input
def read_input(self): """Section 3 - Read Input File (.m, file) Note: UWG_Matlab input files are xlsm, XML, .m, file. properties: self._init_param_dict # dictionary of simulation initialization parameters self.sensAnth # non-building sensible heat (W/m^...
python
def read_input(self): """Section 3 - Read Input File (.m, file) Note: UWG_Matlab input files are xlsm, XML, .m, file. properties: self._init_param_dict # dictionary of simulation initialization parameters self.sensAnth # non-building sensible heat (W/m^...
[ "def", "read_input", "(", "self", ")", ":", "uwg_param_file_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "uwgParamDir", ",", "self", ".", "uwgParamFileName", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "uwg_param_file_path", ...
Section 3 - Read Input File (.m, file) Note: UWG_Matlab input files are xlsm, XML, .m, file. properties: self._init_param_dict # dictionary of simulation initialization parameters self.sensAnth # non-building sensible heat (W/m^2) self.SchTraffic ...
[ "Section", "3", "-", "Read", "Input", "File", "(", ".", "m", "file", ")", "Note", ":", "UWG_Matlab", "input", "files", "are", "xlsm", "XML", ".", "m", "file", ".", "properties", ":", "self", ".", "_init_param_dict", "#", "dictionary", "of", "simulation",...
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/uwg.py#L299-L436
ladybug-tools/uwg
uwg/uwg.py
uwg.set_input
def set_input(self): """ Set inputs from .uwg input file if not already defined, the check if all the required input parameters are there. """ # If a uwgParamFileName is set, then read inputs from .uwg file. # User-defined class properties will override the inputs from the...
python
def set_input(self): """ Set inputs from .uwg input file if not already defined, the check if all the required input parameters are there. """ # If a uwgParamFileName is set, then read inputs from .uwg file. # User-defined class properties will override the inputs from the...
[ "def", "set_input", "(", "self", ")", ":", "# If a uwgParamFileName is set, then read inputs from .uwg file.\r", "# User-defined class properties will override the inputs from the .uwg file.\r", "if", "self", ".", "uwgParamFileName", "is", "not", "None", ":", "print", "(", "\"\\n...
Set inputs from .uwg input file if not already defined, the check if all the required input parameters are there.
[ "Set", "inputs", "from", ".", "uwg", "input", "file", "if", "not", "already", "defined", "the", "check", "if", "all", "the", "required", "input", "parameters", "are", "there", "." ]
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/uwg.py#L532-L548
ladybug-tools/uwg
uwg/uwg.py
uwg.init_BEM_obj
def init_BEM_obj(self): """ Define BEM for each DOE type (read the fraction) self.BEM # list of BEMDef objects self.r_glaze # Glazing ratio for total building stock self.SHGC # SHGC addition for total building stock self.alb_w...
python
def init_BEM_obj(self): """ Define BEM for each DOE type (read the fraction) self.BEM # list of BEMDef objects self.r_glaze # Glazing ratio for total building stock self.SHGC # SHGC addition for total building stock self.alb_w...
[ "def", "init_BEM_obj", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "readDOE_file_path", ")", ":", "raise", "Exception", "(", "\"readDOE.pkl file: '{}' does not exist.\"", ".", "format", "(", "readDOE_file_path", ")", ...
Define BEM for each DOE type (read the fraction) self.BEM # list of BEMDef objects self.r_glaze # Glazing ratio for total building stock self.SHGC # SHGC addition for total building stock self.alb_wall # albedo wall addition for total...
[ "Define", "BEM", "for", "each", "DOE", "type", "(", "read", "the", "fraction", ")", "self", ".", "BEM", "#", "list", "of", "BEMDef", "objects", "self", ".", "r_glaze", "#", "Glazing", "ratio", "for", "total", "building", "stock", "self", ".", "SHGC", "...
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/uwg.py#L550-L610
ladybug-tools/uwg
uwg/uwg.py
uwg.init_input_obj
def init_input_obj(self): """Section 4 - Create uwg objects from input parameters self.simTime # simulation time parameter obj self.weather # weather obj for simulation time period self.forcIP # Forcing obj self.forc ...
python
def init_input_obj(self): """Section 4 - Create uwg objects from input parameters self.simTime # simulation time parameter obj self.weather # weather obj for simulation time period self.forcIP # Forcing obj self.forc ...
[ "def", "init_input_obj", "(", "self", ")", ":", "climate_file_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "epwDir", ",", "self", ".", "epwFileName", ")", "self", ".", "simTime", "=", "SimParam", "(", "self", ".", "dtSim", ",", "self",...
Section 4 - Create uwg objects from input parameters self.simTime # simulation time parameter obj self.weather # weather obj for simulation time period self.forcIP # Forcing obj self.forc # Empty forcing obj ...
[ "Section", "4", "-", "Create", "uwg", "objects", "from", "input", "parameters", "self", ".", "simTime", "#", "simulation", "time", "parameter", "obj", "self", ".", "weather", "#", "weather", "obj", "for", "simulation", "time", "period", "self", ".", "forcIP"...
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/uwg.py#L612-L727
ladybug-tools/uwg
uwg/uwg.py
uwg.hvac_autosize
def hvac_autosize(self): """ Section 6 - HVAC Autosizing (unlimited cooling & heating) """ for i in range(len(self.BEM)): if self.is_near_zero(self.autosize) == False: self.BEM[i].building.coolCap = 9999. self.BEM[i].building.heatCap = 9999.
python
def hvac_autosize(self): """ Section 6 - HVAC Autosizing (unlimited cooling & heating) """ for i in range(len(self.BEM)): if self.is_near_zero(self.autosize) == False: self.BEM[i].building.coolCap = 9999. self.BEM[i].building.heatCap = 9999.
[ "def", "hvac_autosize", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "BEM", ")", ")", ":", "if", "self", ".", "is_near_zero", "(", "self", ".", "autosize", ")", "==", "False", ":", "self", ".", "BEM", "[", "i", ...
Section 6 - HVAC Autosizing (unlimited cooling & heating)
[ "Section", "6", "-", "HVAC", "Autosizing", "(", "unlimited", "cooling", "&", "heating", ")" ]
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/uwg.py#L729-L735
ladybug-tools/uwg
uwg/uwg.py
uwg.simulate
def simulate(self): """ Section 7 - uwg main section self.N # Total hours in simulation self.ph # per hour self.dayType # 3=Sun, 2=Sat, 1=Weekday self.ceil_time_step # simulation timestep (dt) fitted to weathe...
python
def simulate(self): """ Section 7 - uwg main section self.N # Total hours in simulation self.ph # per hour self.dayType # 3=Sun, 2=Sat, 1=Weekday self.ceil_time_step # simulation timestep (dt) fitted to weathe...
[ "def", "simulate", "(", "self", ")", ":", "self", ".", "N", "=", "int", "(", "self", ".", "simTime", ".", "days", "*", "24", ")", "# total number of hours in simulation\r", "n", "=", "0", "# weather time step counter\r", "self", ".", "ph", "=", "self", "."...
Section 7 - uwg main section self.N # Total hours in simulation self.ph # per hour self.dayType # 3=Sun, 2=Sat, 1=Weekday self.ceil_time_step # simulation timestep (dt) fitted to weather file timestep # ...
[ "Section", "7", "-", "uwg", "main", "section", "self", ".", "N", "#", "Total", "hours", "in", "simulation", "self", ".", "ph", "#", "per", "hour", "self", ".", "dayType", "#", "3", "=", "Sun", "2", "=", "Sat", "1", "=", "Weekday", "self", ".", "c...
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/uwg.py#L737-L924
ladybug-tools/uwg
uwg/uwg.py
uwg.write_epw
def write_epw(self): """ Section 8 - Writing new EPW file """ epw_prec = self.epw_precision # precision of epw file input for iJ in range(len(self.UCMData)): # [iJ+self.simTime.timeInitial-8] = increments along every weather timestep in epw # [6 to 21] ...
python
def write_epw(self): """ Section 8 - Writing new EPW file """ epw_prec = self.epw_precision # precision of epw file input for iJ in range(len(self.UCMData)): # [iJ+self.simTime.timeInitial-8] = increments along every weather timestep in epw # [6 to 21] ...
[ "def", "write_epw", "(", "self", ")", ":", "epw_prec", "=", "self", ".", "epw_precision", "# precision of epw file input\r", "for", "iJ", "in", "range", "(", "len", "(", "self", ".", "UCMData", ")", ")", ":", "# [iJ+self.simTime.timeInitial-8] = increments along eve...
Section 8 - Writing new EPW file
[ "Section", "8", "-", "Writing", "new", "EPW", "file" ]
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/uwg.py#L926-L963
ladybug-tools/uwg
uwg/element.py
Element.SurfFlux
def SurfFlux(self,forc,parameter,simTime,humRef,tempRef,windRef,boundCond,intFlux): """ Calculate net heat flux, and update element layer temperatures """ # Calculated per unit area (m^2) dens = forc.pres/(1000*0.287042*tempRef*(1.+1.607858*humRef)) # air density (kgd m-3) self....
python
def SurfFlux(self,forc,parameter,simTime,humRef,tempRef,windRef,boundCond,intFlux): """ Calculate net heat flux, and update element layer temperatures """ # Calculated per unit area (m^2) dens = forc.pres/(1000*0.287042*tempRef*(1.+1.607858*humRef)) # air density (kgd m-3) self....
[ "def", "SurfFlux", "(", "self", ",", "forc", ",", "parameter", ",", "simTime", ",", "humRef", ",", "tempRef", ",", "windRef", ",", "boundCond", ",", "intFlux", ")", ":", "# Calculated per unit area (m^2)", "dens", "=", "forc", ".", "pres", "/", "(", "1000"...
Calculate net heat flux, and update element layer temperatures
[ "Calculate", "net", "heat", "flux", "and", "update", "element", "layer", "temperatures" ]
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/element.py#L97-L145
ladybug-tools/uwg
uwg/element.py
Element.Conduction
def Conduction(self, dt, flx1, bc, temp2, flx2): """ Solve the conductance of heat based on of the element layers. arg: flx1 : net heat flux on surface bc : boundary condition parameter (1 or 2) temp2 : deep soil temperature (ave of air temperature) ...
python
def Conduction(self, dt, flx1, bc, temp2, flx2): """ Solve the conductance of heat based on of the element layers. arg: flx1 : net heat flux on surface bc : boundary condition parameter (1 or 2) temp2 : deep soil temperature (ave of air temperature) ...
[ "def", "Conduction", "(", "self", ",", "dt", ",", "flx1", ",", "bc", ",", "temp2", ",", "flx2", ")", ":", "t", "=", "self", ".", "layerTemp", "# vector of layer temperatures (K)", "hc", "=", "self", ".", "layerVolHeat", "# vector of layer volumetric heat (J m-3 ...
Solve the conductance of heat based on of the element layers. arg: flx1 : net heat flux on surface bc : boundary condition parameter (1 or 2) temp2 : deep soil temperature (ave of air temperature) flx2 : surface flux (sum of absorbed, emitted, etc.) ...
[ "Solve", "the", "conductance", "of", "heat", "based", "on", "of", "the", "element", "layers", ".", "arg", ":", "flx1", ":", "net", "heat", "flux", "on", "surface", "bc", ":", "boundary", "condition", "parameter", "(", "1", "or", "2", ")", "temp2", ":",...
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/element.py#L147-L231
ladybug-tools/uwg
uwg/element.py
Element.qsat
def qsat(self,temp,pres,parameter): """ Calculate (qsat_lst) vector of saturation humidity from: temp = vector of element layer temperatures pres = pressure (at current timestep). """ gamw = (parameter.cl - parameter.cpv) / parameter.rv betaw = (parameter....
python
def qsat(self,temp,pres,parameter): """ Calculate (qsat_lst) vector of saturation humidity from: temp = vector of element layer temperatures pres = pressure (at current timestep). """ gamw = (parameter.cl - parameter.cpv) / parameter.rv betaw = (parameter....
[ "def", "qsat", "(", "self", ",", "temp", ",", "pres", ",", "parameter", ")", ":", "gamw", "=", "(", "parameter", ".", "cl", "-", "parameter", ".", "cpv", ")", "/", "parameter", ".", "rv", "betaw", "=", "(", "parameter", ".", "lvtt", "/", "parameter...
Calculate (qsat_lst) vector of saturation humidity from: temp = vector of element layer temperatures pres = pressure (at current timestep).
[ "Calculate", "(", "qsat_lst", ")", "vector", "of", "saturation", "humidity", "from", ":", "temp", "=", "vector", "of", "element", "layer", "temperatures", "pres", "=", "pressure", "(", "at", "current", "timestep", ")", "." ]
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/element.py#L233-L254
ladybug-tools/uwg
uwg/element.py
Element.invert
def invert(self,nz,A,C): """ Inversion and resolution of a tridiagonal matrix A X = C Input: nz number of layers a(*,1) lower diagonal (Ai,i-1) a(*,2) principal diagonal (Ai,i) a(*,3) upper diagonal (Ai,i+1) c Output ...
python
def invert(self,nz,A,C): """ Inversion and resolution of a tridiagonal matrix A X = C Input: nz number of layers a(*,1) lower diagonal (Ai,i-1) a(*,2) principal diagonal (Ai,i) a(*,3) upper diagonal (Ai,i+1) c Output ...
[ "def", "invert", "(", "self", ",", "nz", ",", "A", ",", "C", ")", ":", "X", "=", "[", "0", "for", "i", "in", "range", "(", "nz", ")", "]", "for", "i", "in", "reversed", "(", "range", "(", "nz", "-", "1", ")", ")", ":", "C", "[", "i", "]...
Inversion and resolution of a tridiagonal matrix A X = C Input: nz number of layers a(*,1) lower diagonal (Ai,i-1) a(*,2) principal diagonal (Ai,i) a(*,3) upper diagonal (Ai,i+1) c Output x results
[ "Inversion", "and", "resolution", "of", "a", "tridiagonal", "matrix", "A", "X", "=", "C", "Input", ":", "nz", "number", "of", "layers", "a", "(", "*", "1", ")", "lower", "diagonal", "(", "Ai", "i", "-", "1", ")", "a", "(", "*", "2", ")", "princip...
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/element.py#L257-L283
ladybug-tools/uwg
uwg/readDOE.py
readDOE
def readDOE(serialize_output=True): """ Read csv files of DOE buildings Sheet 1 = BuildingSummary Sheet 2 = ZoneSummary Sheet 3 = LocationSummary Sheet 4 = Schedules Note BLD8 & 10 = school Then make matrix of ref data as nested nested lists [16, 3, 16]: matrix refDOE = Building ob...
python
def readDOE(serialize_output=True): """ Read csv files of DOE buildings Sheet 1 = BuildingSummary Sheet 2 = ZoneSummary Sheet 3 = LocationSummary Sheet 4 = Schedules Note BLD8 & 10 = school Then make matrix of ref data as nested nested lists [16, 3, 16]: matrix refDOE = Building ob...
[ "def", "readDOE", "(", "serialize_output", "=", "True", ")", ":", "#Nested, nested lists of Building, SchDef, BEMDef objects", "refDOE", "=", "[", "[", "[", "None", "]", "*", "16", "for", "k_", "in", "range", "(", "3", ")", "]", "for", "j_", "in", "range", ...
Read csv files of DOE buildings Sheet 1 = BuildingSummary Sheet 2 = ZoneSummary Sheet 3 = LocationSummary Sheet 4 = Schedules Note BLD8 & 10 = school Then make matrix of ref data as nested nested lists [16, 3, 16]: matrix refDOE = Building objs matrix Schedule = SchDef objs matrix ...
[ "Read", "csv", "files", "of", "DOE", "buildings", "Sheet", "1", "=", "BuildingSummary", "Sheet", "2", "=", "ZoneSummary", "Sheet", "3", "=", "LocationSummary", "Sheet", "4", "=", "Schedules", "Note", "BLD8", "&", "10", "=", "school" ]
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/readDOE.py#L79-L374
wooster/biplist
biplist/__init__.py
readPlist
def readPlist(pathOrFile): """Raises NotBinaryPlistException, InvalidPlistException""" didOpen = False result = None if isinstance(pathOrFile, (bytes, unicode)): pathOrFile = open(pathOrFile, 'rb') didOpen = True try: reader = PlistReader(pathOrFile) result = reader.p...
python
def readPlist(pathOrFile): """Raises NotBinaryPlistException, InvalidPlistException""" didOpen = False result = None if isinstance(pathOrFile, (bytes, unicode)): pathOrFile = open(pathOrFile, 'rb') didOpen = True try: reader = PlistReader(pathOrFile) result = reader.p...
[ "def", "readPlist", "(", "pathOrFile", ")", ":", "didOpen", "=", "False", "result", "=", "None", "if", "isinstance", "(", "pathOrFile", ",", "(", "bytes", ",", "unicode", ")", ")", ":", "pathOrFile", "=", "open", "(", "pathOrFile", ",", "'rb'", ")", "d...
Raises NotBinaryPlistException, InvalidPlistException
[ "Raises", "NotBinaryPlistException", "InvalidPlistException" ]
train
https://github.com/wooster/biplist/blob/4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82/biplist/__init__.py#L117-L147
wooster/biplist
biplist/__init__.py
PlistReader.getSizedInteger
def getSizedInteger(self, data, byteSize, as_number=False): """Numbers of 8 bytes are signed integers when they refer to numbers, but unsigned otherwise.""" result = 0 if byteSize == 0: raise InvalidPlistException("Encountered integer with byte size of 0.") # 1, 2, and 4 byte...
python
def getSizedInteger(self, data, byteSize, as_number=False): """Numbers of 8 bytes are signed integers when they refer to numbers, but unsigned otherwise.""" result = 0 if byteSize == 0: raise InvalidPlistException("Encountered integer with byte size of 0.") # 1, 2, and 4 byte...
[ "def", "getSizedInteger", "(", "self", ",", "data", ",", "byteSize", ",", "as_number", "=", "False", ")", ":", "result", "=", "0", "if", "byteSize", "==", "0", ":", "raise", "InvalidPlistException", "(", "\"Encountered integer with byte size of 0.\"", ")", "# 1,...
Numbers of 8 bytes are signed integers when they refer to numbers, but unsigned otherwise.
[ "Numbers", "of", "8", "bytes", "are", "signed", "integers", "when", "they", "refer", "to", "numbers", "but", "unsigned", "otherwise", "." ]
train
https://github.com/wooster/biplist/blob/4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82/biplist/__init__.py#L499-L529
wooster/biplist
biplist/__init__.py
PlistWriter.writeRoot
def writeRoot(self, root): """ Strategy is: - write header - wrap root object so everything is hashable - compute size of objects which will be written - need to do this in order to know how large the object refs will be in the list/dict/set reference lists ...
python
def writeRoot(self, root): """ Strategy is: - write header - wrap root object so everything is hashable - compute size of objects which will be written - need to do this in order to know how large the object refs will be in the list/dict/set reference lists ...
[ "def", "writeRoot", "(", "self", ",", "root", ")", ":", "output", "=", "self", ".", "header", "wrapped_root", "=", "self", ".", "wrapRoot", "(", "root", ")", "self", ".", "computeOffsets", "(", "wrapped_root", ",", "asReference", "=", "True", ",", "isRoo...
Strategy is: - write header - wrap root object so everything is hashable - compute size of objects which will be written - need to do this in order to know how large the object refs will be in the list/dict/set reference lists - write objects - keep object...
[ "Strategy", "is", ":", "-", "write", "header", "-", "wrap", "root", "object", "so", "everything", "is", "hashable", "-", "compute", "size", "of", "objects", "which", "will", "be", "written", "-", "need", "to", "do", "this", "in", "order", "to", "know", ...
train
https://github.com/wooster/biplist/blob/4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82/biplist/__init__.py#L638-L672
wooster/biplist
biplist/__init__.py
PlistWriter.writeObjectReference
def writeObjectReference(self, obj, output): """Tries to write an object reference, adding it to the references table. Does not write the actual object bytes or set the reference position. Returns a tuple of whether the object was a new reference (True if it was, False if it alr...
python
def writeObjectReference(self, obj, output): """Tries to write an object reference, adding it to the references table. Does not write the actual object bytes or set the reference position. Returns a tuple of whether the object was a new reference (True if it was, False if it alr...
[ "def", "writeObjectReference", "(", "self", ",", "obj", ",", "output", ")", ":", "position", "=", "self", ".", "positionOfObjectReference", "(", "obj", ")", "if", "position", "is", "None", ":", "self", ".", "writtenReferences", "[", "obj", "]", "=", "len",...
Tries to write an object reference, adding it to the references table. Does not write the actual object bytes or set the reference position. Returns a tuple of whether the object was a new reference (True if it was, False if it already was in the reference table) and the new ...
[ "Tries", "to", "write", "an", "object", "reference", "adding", "it", "to", "the", "references", "table", ".", "Does", "not", "write", "the", "actual", "object", "bytes", "or", "set", "the", "reference", "position", ".", "Returns", "a", "tuple", "of", "whet...
train
https://github.com/wooster/biplist/blob/4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82/biplist/__init__.py#L797-L811
wooster/biplist
biplist/__init__.py
PlistWriter.writeObject
def writeObject(self, obj, output, setReferencePosition=False): """Serializes the given object to the output. Returns output. If setReferencePosition is True, will set the position the object was written. """ def proc_variable_length(format, length): result = b'...
python
def writeObject(self, obj, output, setReferencePosition=False): """Serializes the given object to the output. Returns output. If setReferencePosition is True, will set the position the object was written. """ def proc_variable_length(format, length): result = b'...
[ "def", "writeObject", "(", "self", ",", "obj", ",", "output", ",", "setReferencePosition", "=", "False", ")", ":", "def", "proc_variable_length", "(", "format", ",", "length", ")", ":", "result", "=", "b''", "if", "length", ">", "0b1110", ":", "result", ...
Serializes the given object to the output. Returns output. If setReferencePosition is True, will set the position the object was written.
[ "Serializes", "the", "given", "object", "to", "the", "output", ".", "Returns", "output", ".", "If", "setReferencePosition", "is", "True", "will", "set", "the", "position", "the", "object", "was", "written", "." ]
train
https://github.com/wooster/biplist/blob/4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82/biplist/__init__.py#L813-L904
wooster/biplist
biplist/__init__.py
PlistWriter.writeOffsetTable
def writeOffsetTable(self, output): """Writes all of the object reference offsets.""" all_positions = [] writtenReferences = list(self.writtenReferences.items()) writtenReferences.sort(key=lambda x: x[1]) for obj,order in writtenReferences: # Porting note: Elsewhere w...
python
def writeOffsetTable(self, output): """Writes all of the object reference offsets.""" all_positions = [] writtenReferences = list(self.writtenReferences.items()) writtenReferences.sort(key=lambda x: x[1]) for obj,order in writtenReferences: # Porting note: Elsewhere w...
[ "def", "writeOffsetTable", "(", "self", ",", "output", ")", ":", "all_positions", "=", "[", "]", "writtenReferences", "=", "list", "(", "self", ".", "writtenReferences", ".", "items", "(", ")", ")", "writtenReferences", ".", "sort", "(", "key", "=", "lambd...
Writes all of the object reference offsets.
[ "Writes", "all", "of", "the", "object", "reference", "offsets", "." ]
train
https://github.com/wooster/biplist/blob/4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82/biplist/__init__.py#L906-L924
wooster/biplist
biplist/__init__.py
PlistWriter.intSize
def intSize(self, obj): """Returns the number of bytes necessary to store the given integer.""" # SIGNED if obj < 0: # Signed integer, always 8 bytes return 8 # UNSIGNED elif obj <= 0xFF: # 1 byte return 1 elif obj <= 0xFFFF: # 2 bytes ...
python
def intSize(self, obj): """Returns the number of bytes necessary to store the given integer.""" # SIGNED if obj < 0: # Signed integer, always 8 bytes return 8 # UNSIGNED elif obj <= 0xFF: # 1 byte return 1 elif obj <= 0xFFFF: # 2 bytes ...
[ "def", "intSize", "(", "self", ",", "obj", ")", ":", "# SIGNED", "if", "obj", "<", "0", ":", "# Signed integer, always 8 bytes", "return", "8", "# UNSIGNED", "elif", "obj", "<=", "0xFF", ":", "# 1 byte", "return", "1", "elif", "obj", "<=", "0xFFFF", ":", ...
Returns the number of bytes necessary to store the given integer.
[ "Returns", "the", "number", "of", "bytes", "necessary", "to", "store", "the", "given", "integer", "." ]
train
https://github.com/wooster/biplist/blob/4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82/biplist/__init__.py#L955-L974
ladybug-tools/uwg
uwg/RSMDef.py
RSMDef.load_z_meso
def load_z_meso(self,z_meso_path): """ Open the z_meso.txt file and return heights as list """ self.z_meso = [] z_meso_file_path = os.path.join(z_meso_path, self.Z_MESO_FILE_NAME) # Check if exists if not os.path.exists(z_meso_file_path): raise Exception("z_meso.txt...
python
def load_z_meso(self,z_meso_path): """ Open the z_meso.txt file and return heights as list """ self.z_meso = [] z_meso_file_path = os.path.join(z_meso_path, self.Z_MESO_FILE_NAME) # Check if exists if not os.path.exists(z_meso_file_path): raise Exception("z_meso.txt...
[ "def", "load_z_meso", "(", "self", ",", "z_meso_path", ")", ":", "self", ".", "z_meso", "=", "[", "]", "z_meso_file_path", "=", "os", ".", "path", ".", "join", "(", "z_meso_path", ",", "self", ".", "Z_MESO_FILE_NAME", ")", "# Check if exists", "if", "not",...
Open the z_meso.txt file and return heights as list
[ "Open", "the", "z_meso", ".", "txt", "file", "and", "return", "heights", "as", "list" ]
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/RSMDef.py#L140-L154
ladybug-tools/uwg
uwg/urbflux.py
urbflux
def urbflux(UCM, UBL, BEM, forc, parameter, simTime, RSM): """ Calculate the surface heat fluxes Output: [UCM,UBL,BEM] """ T_can = UCM.canTemp Cp = parameter.cp UCM.Q_roof = 0. sigma = 5.67e-8 # Stephan-Boltzman constant UCM.roofTemp = 0. # Average urban roof temperatur...
python
def urbflux(UCM, UBL, BEM, forc, parameter, simTime, RSM): """ Calculate the surface heat fluxes Output: [UCM,UBL,BEM] """ T_can = UCM.canTemp Cp = parameter.cp UCM.Q_roof = 0. sigma = 5.67e-8 # Stephan-Boltzman constant UCM.roofTemp = 0. # Average urban roof temperatur...
[ "def", "urbflux", "(", "UCM", ",", "UBL", ",", "BEM", ",", "forc", ",", "parameter", ",", "simTime", ",", "RSM", ")", ":", "T_can", "=", "UCM", ".", "canTemp", "Cp", "=", "parameter", ".", "cp", "UCM", ".", "Q_roof", "=", "0.", "sigma", "=", "5.6...
Calculate the surface heat fluxes Output: [UCM,UBL,BEM]
[ "Calculate", "the", "surface", "heat", "fluxes", "Output", ":", "[", "UCM", "UBL", "BEM", "]" ]
train
https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/urbflux.py#L12-L136
sleepyfran/itunespy
itunespy/ebook_artist.py
EbookArtist.get_books
def get_books(self): """ Retrieves all the books published by the artist :return: List. Books published by the artist """ return itunespy.lookup(id=self.artist_id, entity=itunespy.entities['ebook'])[1:]
python
def get_books(self): """ Retrieves all the books published by the artist :return: List. Books published by the artist """ return itunespy.lookup(id=self.artist_id, entity=itunespy.entities['ebook'])[1:]
[ "def", "get_books", "(", "self", ")", ":", "return", "itunespy", ".", "lookup", "(", "id", "=", "self", ".", "artist_id", ",", "entity", "=", "itunespy", ".", "entities", "[", "'ebook'", "]", ")", "[", "1", ":", "]" ]
Retrieves all the books published by the artist :return: List. Books published by the artist
[ "Retrieves", "all", "the", "books", "published", "by", "the", "artist", ":", "return", ":", "List", ".", "Books", "published", "by", "the", "artist" ]
train
https://github.com/sleepyfran/itunespy/blob/0e7e931b135b5e0daae49ba68e9167ff4ac73eb5/itunespy/ebook_artist.py#L29-L34
dcos/shakedown
shakedown/dcos/task.py
get_tasks
def get_tasks(task_id='', completed=True): """ Get a list of tasks, optionally filtered by task id. The task_id can be the abbrevated. Example: If a task named 'sleep' is scaled to 3 in marathon, there will be be 3 tasks starting with 'sleep.' :param task_id: task ID :type task_id:...
python
def get_tasks(task_id='', completed=True): """ Get a list of tasks, optionally filtered by task id. The task_id can be the abbrevated. Example: If a task named 'sleep' is scaled to 3 in marathon, there will be be 3 tasks starting with 'sleep.' :param task_id: task ID :type task_id:...
[ "def", "get_tasks", "(", "task_id", "=", "''", ",", "completed", "=", "True", ")", ":", "client", "=", "mesos", ".", "DCOSClient", "(", ")", "master", "=", "mesos", ".", "Master", "(", "client", ".", "get_master_state", "(", ")", ")", "mesos_tasks", "=...
Get a list of tasks, optionally filtered by task id. The task_id can be the abbrevated. Example: If a task named 'sleep' is scaled to 3 in marathon, there will be be 3 tasks starting with 'sleep.' :param task_id: task ID :type task_id: str :param completed: include completed ta...
[ "Get", "a", "list", "of", "tasks", "optionally", "filtered", "by", "task", "id", ".", "The", "task_id", "can", "be", "the", "abbrevated", ".", "Example", ":", "If", "a", "task", "named", "sleep", "is", "scaled", "to", "3", "in", "marathon", "there", "w...
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/task.py#L12-L29
dcos/shakedown
shakedown/dcos/task.py
get_task
def get_task(task_id, completed=True): """ Get a task by task id where a task_id is required. :param task_id: task ID :type task_id: str :param completed: include completed tasks? :type completed: bool :return: a task :rtype: obj """ tasks = get_tasks(task_i...
python
def get_task(task_id, completed=True): """ Get a task by task id where a task_id is required. :param task_id: task ID :type task_id: str :param completed: include completed tasks? :type completed: bool :return: a task :rtype: obj """ tasks = get_tasks(task_i...
[ "def", "get_task", "(", "task_id", ",", "completed", "=", "True", ")", ":", "tasks", "=", "get_tasks", "(", "task_id", "=", "task_id", ",", "completed", "=", "completed", ")", "if", "len", "(", "tasks", ")", "==", "0", ":", "return", "None", "assert", ...
Get a task by task id where a task_id is required. :param task_id: task ID :type task_id: str :param completed: include completed tasks? :type completed: bool :return: a task :rtype: obj
[ "Get", "a", "task", "by", "task", "id", "where", "a", "task_id", "is", "required", "." ]
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/task.py#L32-L49
dcos/shakedown
shakedown/dcos/task.py
task_completed
def task_completed(task_id): """ Check whether a task has completed. :param task_id: task ID :type task_id: str :return: True if completed, False otherwise :rtype: bool """ tasks = get_tasks(task_id=task_id) completed_states = ('TASK_FINISHED', ...
python
def task_completed(task_id): """ Check whether a task has completed. :param task_id: task ID :type task_id: str :return: True if completed, False otherwise :rtype: bool """ tasks = get_tasks(task_id=task_id) completed_states = ('TASK_FINISHED', ...
[ "def", "task_completed", "(", "task_id", ")", ":", "tasks", "=", "get_tasks", "(", "task_id", "=", "task_id", ")", "completed_states", "=", "(", "'TASK_FINISHED'", ",", "'TASK_FAILED'", ",", "'TASK_KILLED'", ",", "'TASK_LOST'", ",", "'TASK_ERROR'", ")", "for", ...
Check whether a task has completed. :param task_id: task ID :type task_id: str :return: True if completed, False otherwise :rtype: bool
[ "Check", "whether", "a", "task", "has", "completed", "." ]
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/task.py#L59-L80
dcos/shakedown
shakedown/dcos/task.py
task_property_present_predicate
def task_property_present_predicate(service, task, prop): """ True if the json_element passed is present for the task specified. """ try: response = get_service_task(service, task) except Exception as e: pass return (response is not None) and (prop in response)
python
def task_property_present_predicate(service, task, prop): """ True if the json_element passed is present for the task specified. """ try: response = get_service_task(service, task) except Exception as e: pass return (response is not None) and (prop in response)
[ "def", "task_property_present_predicate", "(", "service", ",", "task", ",", "prop", ")", ":", "try", ":", "response", "=", "get_service_task", "(", "service", ",", "task", ")", "except", "Exception", "as", "e", ":", "pass", "return", "(", "response", "is", ...
True if the json_element passed is present for the task specified.
[ "True", "if", "the", "json_element", "passed", "is", "present", "for", "the", "task", "specified", "." ]
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/task.py#L107-L115
dcos/shakedown
shakedown/dcos/task.py
wait_for_task
def wait_for_task(service, task, timeout_sec=120): """Waits for a task which was launched to be launched""" return time_wait(lambda: task_predicate(service, task), timeout_seconds=timeout_sec)
python
def wait_for_task(service, task, timeout_sec=120): """Waits for a task which was launched to be launched""" return time_wait(lambda: task_predicate(service, task), timeout_seconds=timeout_sec)
[ "def", "wait_for_task", "(", "service", ",", "task", ",", "timeout_sec", "=", "120", ")", ":", "return", "time_wait", "(", "lambda", ":", "task_predicate", "(", "service", ",", "task", ")", ",", "timeout_seconds", "=", "timeout_sec", ")" ]
Waits for a task which was launched to be launched
[ "Waits", "for", "a", "task", "which", "was", "launched", "to", "be", "launched" ]
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/task.py#L118-L120
dcos/shakedown
shakedown/dcos/task.py
wait_for_task_property
def wait_for_task_property(service, task, prop, timeout_sec=120): """Waits for a task to have the specified property""" return time_wait(lambda: task_property_present_predicate(service, task, prop), timeout_seconds=timeout_sec)
python
def wait_for_task_property(service, task, prop, timeout_sec=120): """Waits for a task to have the specified property""" return time_wait(lambda: task_property_present_predicate(service, task, prop), timeout_seconds=timeout_sec)
[ "def", "wait_for_task_property", "(", "service", ",", "task", ",", "prop", ",", "timeout_sec", "=", "120", ")", ":", "return", "time_wait", "(", "lambda", ":", "task_property_present_predicate", "(", "service", ",", "task", ",", "prop", ")", ",", "timeout_seco...
Waits for a task to have the specified property
[ "Waits", "for", "a", "task", "to", "have", "the", "specified", "property" ]
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/task.py#L123-L125
dcos/shakedown
shakedown/dcos/file.py
copy_file
def copy_file( host, file_path, remote_path='.', username=None, key_path=None, action='put' ): """ Copy a file via SCP, proxied through the mesos master :param host: host or IP of the machine to execute the command on :type host: str :param fi...
python
def copy_file( host, file_path, remote_path='.', username=None, key_path=None, action='put' ): """ Copy a file via SCP, proxied through the mesos master :param host: host or IP of the machine to execute the command on :type host: str :param fi...
[ "def", "copy_file", "(", "host", ",", "file_path", ",", "remote_path", "=", "'.'", ",", "username", "=", "None", ",", "key_path", "=", "None", ",", "action", "=", "'put'", ")", ":", "if", "not", "username", ":", "username", "=", "shakedown", ".", "cli"...
Copy a file via SCP, proxied through the mesos master :param host: host or IP of the machine to execute the command on :type host: str :param file_path: the local path to the file to be copied :type file_path: str :param remote_path: the remote path to copy the file to :...
[ "Copy", "a", "file", "via", "SCP", "proxied", "through", "the", "mesos", "master" ]
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/file.py#L10-L66
dcos/shakedown
shakedown/dcos/file.py
copy_file_to_master
def copy_file_to_master( file_path, remote_path='.', username=None, key_path=None ): """ Copy a file to the Mesos master """ return copy_file(shakedown.master_ip(), file_path, remote_path, username, key_path)
python
def copy_file_to_master( file_path, remote_path='.', username=None, key_path=None ): """ Copy a file to the Mesos master """ return copy_file(shakedown.master_ip(), file_path, remote_path, username, key_path)
[ "def", "copy_file_to_master", "(", "file_path", ",", "remote_path", "=", "'.'", ",", "username", "=", "None", ",", "key_path", "=", "None", ")", ":", "return", "copy_file", "(", "shakedown", ".", "master_ip", "(", ")", ",", "file_path", ",", "remote_path", ...
Copy a file to the Mesos master
[ "Copy", "a", "file", "to", "the", "Mesos", "master" ]
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/file.py#L69-L78
dcos/shakedown
shakedown/dcos/file.py
copy_file_to_agent
def copy_file_to_agent( host, file_path, remote_path='.', username=None, key_path=None ): """ Copy a file to a Mesos agent, proxied through the master """ return copy_file(host, file_path, remote_path, username, key_path)
python
def copy_file_to_agent( host, file_path, remote_path='.', username=None, key_path=None ): """ Copy a file to a Mesos agent, proxied through the master """ return copy_file(host, file_path, remote_path, username, key_path)
[ "def", "copy_file_to_agent", "(", "host", ",", "file_path", ",", "remote_path", "=", "'.'", ",", "username", "=", "None", ",", "key_path", "=", "None", ")", ":", "return", "copy_file", "(", "host", ",", "file_path", ",", "remote_path", ",", "username", ","...
Copy a file to a Mesos agent, proxied through the master
[ "Copy", "a", "file", "to", "a", "Mesos", "agent", "proxied", "through", "the", "master" ]
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/file.py#L81-L91
dcos/shakedown
shakedown/dcos/file.py
copy_file_from_master
def copy_file_from_master( remote_path, file_path='.', username=None, key_path=None ): """ Copy a file to the Mesos master """ return copy_file(shakedown.master_ip(), file_path, remote_path, username, key_path, 'get')
python
def copy_file_from_master( remote_path, file_path='.', username=None, key_path=None ): """ Copy a file to the Mesos master """ return copy_file(shakedown.master_ip(), file_path, remote_path, username, key_path, 'get')
[ "def", "copy_file_from_master", "(", "remote_path", ",", "file_path", "=", "'.'", ",", "username", "=", "None", ",", "key_path", "=", "None", ")", ":", "return", "copy_file", "(", "shakedown", ".", "master_ip", "(", ")", ",", "file_path", ",", "remote_path",...
Copy a file to the Mesos master
[ "Copy", "a", "file", "to", "the", "Mesos", "master" ]
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/file.py#L94-L103
dcos/shakedown
shakedown/dcos/file.py
copy_file_from_agent
def copy_file_from_agent( host, remote_path, file_path='.', username=None, key_path=None ): """ Copy a file to a Mesos agent, proxied through the master """ return copy_file(host, file_path, remote_path, username, key_path, 'get')
python
def copy_file_from_agent( host, remote_path, file_path='.', username=None, key_path=None ): """ Copy a file to a Mesos agent, proxied through the master """ return copy_file(host, file_path, remote_path, username, key_path, 'get')
[ "def", "copy_file_from_agent", "(", "host", ",", "remote_path", ",", "file_path", "=", "'.'", ",", "username", "=", "None", ",", "key_path", "=", "None", ")", ":", "return", "copy_file", "(", "host", ",", "file_path", ",", "remote_path", ",", "username", "...
Copy a file to a Mesos agent, proxied through the master
[ "Copy", "a", "file", "to", "a", "Mesos", "agent", "proxied", "through", "the", "master" ]
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/file.py#L106-L116
dcos/shakedown
shakedown/dcos/cluster.py
__metadata_helper
def __metadata_helper(json_path): """ Returns json for specific cluster metadata. Important to realize that this was introduced in dcos-1.9. Clusters prior to 1.9 and missing metadata will return None """ url = shakedown.dcos_url_path('dcos-metadata/{}'.format(json_path)) try: ...
python
def __metadata_helper(json_path): """ Returns json for specific cluster metadata. Important to realize that this was introduced in dcos-1.9. Clusters prior to 1.9 and missing metadata will return None """ url = shakedown.dcos_url_path('dcos-metadata/{}'.format(json_path)) try: ...
[ "def", "__metadata_helper", "(", "json_path", ")", ":", "url", "=", "shakedown", ".", "dcos_url_path", "(", "'dcos-metadata/{}'", ".", "format", "(", "json_path", ")", ")", "try", ":", "response", "=", "dcos", ".", "http", ".", "request", "(", "'get'", ","...
Returns json for specific cluster metadata. Important to realize that this was introduced in dcos-1.9. Clusters prior to 1.9 and missing metadata will return None
[ "Returns", "json", "for", "specific", "cluster", "metadata", ".", "Important", "to", "realize", "that", "this", "was", "introduced", "in", "dcos", "-", "1", ".", "9", ".", "Clusters", "prior", "to", "1", ".", "9", "and", "missing", "metadata", "will", "r...
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/cluster.py#L93-L107
dcos/shakedown
shakedown/dcos/cluster.py
_get_resources
def _get_resources(rtype='resources'): """ resource types from state summary include: resources, used_resources offered_resources, reserved_resources, unreserved_resources The default is resources. :param rtype: the type of resources to return :type rtype: str :param role: the name of the role...
python
def _get_resources(rtype='resources'): """ resource types from state summary include: resources, used_resources offered_resources, reserved_resources, unreserved_resources The default is resources. :param rtype: the type of resources to return :type rtype: str :param role: the name of the role...
[ "def", "_get_resources", "(", "rtype", "=", "'resources'", ")", ":", "cpus", "=", "0", "mem", "=", "0", "summary", "=", "DCOSClient", "(", ")", ".", "get_state_summary", "(", ")", "if", "'slaves'", "in", "summary", ":", "agents", "=", "summary", ".", "...
resource types from state summary include: resources, used_resources offered_resources, reserved_resources, unreserved_resources The default is resources. :param rtype: the type of resources to return :type rtype: str :param role: the name of the role if for reserved and if None all reserved :...
[ "resource", "types", "from", "state", "summary", "include", ":", "resources", "used_resources", "offered_resources", "reserved_resources", "unreserved_resources", "The", "default", "is", "resources", "." ]
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/cluster.py#L165-L190
dcos/shakedown
shakedown/dcos/cluster.py
get_reserved_resources
def get_reserved_resources(role=None): """ resource types from state summary include: reserved_resources :param role: the name of the role if for reserved and if None all reserved :type role: str :return: resources(cpu,mem) :rtype: Resources """ rtype = 'reserved_resources' cpus = 0.0 ...
python
def get_reserved_resources(role=None): """ resource types from state summary include: reserved_resources :param role: the name of the role if for reserved and if None all reserved :type role: str :return: resources(cpu,mem) :rtype: Resources """ rtype = 'reserved_resources' cpus = 0.0 ...
[ "def", "get_reserved_resources", "(", "role", "=", "None", ")", ":", "rtype", "=", "'reserved_resources'", "cpus", "=", "0.0", "mem", "=", "0.0", "summary", "=", "DCOSClient", "(", ")", ".", "get_state_summary", "(", ")", "if", "'slaves'", "in", "summary", ...
resource types from state summary include: reserved_resources :param role: the name of the role if for reserved and if None all reserved :type role: str :return: resources(cpu,mem) :rtype: Resources
[ "resource", "types", "from", "state", "summary", "include", ":", "reserved_resources" ]
train
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/cluster.py#L193-L222
openstax/cnx-easybake
cnxeasybake/oven.py
log_decl_method
def log_decl_method(func): """Decorate do_declartion methods for debug logging.""" from functools import wraps @wraps(func) def with_logging(*args, **kwargs): self = args[0] decl = args[2] log(DEBUG, u" {}: {} {}".format( self.state['current_step'], decl.name, ...
python
def log_decl_method(func): """Decorate do_declartion methods for debug logging.""" from functools import wraps @wraps(func) def with_logging(*args, **kwargs): self = args[0] decl = args[2] log(DEBUG, u" {}: {} {}".format( self.state['current_step'], decl.name, ...
[ "def", "log_decl_method", "(", "func", ")", ":", "from", "functools", "import", "wraps", "@", "wraps", "(", "func", ")", "def", "with_logging", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", "=", "args", "[", "0", "]", "decl", "=", "a...
Decorate do_declartion methods for debug logging.
[ "Decorate", "do_declartion", "methods", "for", "debug", "logging", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L59-L71
openstax/cnx-easybake
cnxeasybake/oven.py
css_to_func
def css_to_func(css, flags, css_namespaces, lang): """Convert a css selector to an xpath, supporting pseudo elements.""" from cssselect import parse, HTMLTranslator from cssselect.parser import FunctionalPseudoElement # FIXME HACK need lessc to support functional-pseudo-selectors instead # of mark...
python
def css_to_func(css, flags, css_namespaces, lang): """Convert a css selector to an xpath, supporting pseudo elements.""" from cssselect import parse, HTMLTranslator from cssselect.parser import FunctionalPseudoElement # FIXME HACK need lessc to support functional-pseudo-selectors instead # of mark...
[ "def", "css_to_func", "(", "css", ",", "flags", ",", "css_namespaces", ",", "lang", ")", ":", "from", "cssselect", "import", "parse", ",", "HTMLTranslator", "from", "cssselect", ".", "parser", "import", "FunctionalPseudoElement", "# FIXME HACK need lessc to support f...
Convert a css selector to an xpath, supporting pseudo elements.
[ "Convert", "a", "css", "selector", "to", "an", "xpath", "supporting", "pseudo", "elements", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1335-L1387
openstax/cnx-easybake
cnxeasybake/oven.py
append_string
def append_string(t, string): """Append a string to a node, as text or tail of last child.""" node = t.tree if string: if len(node) == 0: if node.text is not None: node.text += string else: node.text = string else: # Get last child ...
python
def append_string(t, string): """Append a string to a node, as text or tail of last child.""" node = t.tree if string: if len(node) == 0: if node.text is not None: node.text += string else: node.text = string else: # Get last child ...
[ "def", "append_string", "(", "t", ",", "string", ")", ":", "node", "=", "t", ".", "tree", "if", "string", ":", "if", "len", "(", "node", ")", "==", "0", ":", "if", "node", ".", "text", "is", "not", "None", ":", "node", ".", "text", "+=", "strin...
Append a string to a node, as text or tail of last child.
[ "Append", "a", "string", "to", "a", "node", "as", "text", "or", "tail", "of", "last", "child", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1390-L1404
openstax/cnx-easybake
cnxeasybake/oven.py
prepend_string
def prepend_string(t, string): """Prepend a string to a target node as text.""" node = t.tree if node.text is not None: node.text += string else: node.text = string
python
def prepend_string(t, string): """Prepend a string to a target node as text.""" node = t.tree if node.text is not None: node.text += string else: node.text = string
[ "def", "prepend_string", "(", "t", ",", "string", ")", ":", "node", "=", "t", ".", "tree", "if", "node", ".", "text", "is", "not", "None", ":", "node", ".", "text", "+=", "string", "else", ":", "node", ".", "text", "=", "string" ]
Prepend a string to a target node as text.
[ "Prepend", "a", "string", "to", "a", "target", "node", "as", "text", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1407-L1413
openstax/cnx-easybake
cnxeasybake/oven.py
grouped_insert
def grouped_insert(t, value): """Insert value into the target tree 't' with correct grouping.""" collator = Collator.createInstance(Locale(t.lang) if t.lang else Locale()) if value.tail is not None: val_prev = value.getprevious() if val_prev is not None: val_prev.tail = (val_prev...
python
def grouped_insert(t, value): """Insert value into the target tree 't' with correct grouping.""" collator = Collator.createInstance(Locale(t.lang) if t.lang else Locale()) if value.tail is not None: val_prev = value.getprevious() if val_prev is not None: val_prev.tail = (val_prev...
[ "def", "grouped_insert", "(", "t", ",", "value", ")", ":", "collator", "=", "Collator", ".", "createInstance", "(", "Locale", "(", "t", ".", "lang", ")", "if", "t", ".", "lang", "else", "Locale", "(", ")", ")", "if", "value", ".", "tail", "is", "no...
Insert value into the target tree 't' with correct grouping.
[ "Insert", "value", "into", "the", "target", "tree", "t", "with", "correct", "grouping", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1416-L1479
openstax/cnx-easybake
cnxeasybake/oven.py
insert_sort
def insert_sort(node, target): """Insert node into sorted position in target tree. Uses sort function and language from target""" sort = target.sort lang = target.lang collator = Collator.createInstance(Locale(lang) if lang else Locale()) for child in target.tree: if collator.compare(so...
python
def insert_sort(node, target): """Insert node into sorted position in target tree. Uses sort function and language from target""" sort = target.sort lang = target.lang collator = Collator.createInstance(Locale(lang) if lang else Locale()) for child in target.tree: if collator.compare(so...
[ "def", "insert_sort", "(", "node", ",", "target", ")", ":", "sort", "=", "target", ".", "sort", "lang", "=", "target", ".", "lang", "collator", "=", "Collator", ".", "createInstance", "(", "Locale", "(", "lang", ")", "if", "lang", "else", "Locale", "("...
Insert node into sorted position in target tree. Uses sort function and language from target
[ "Insert", "node", "into", "sorted", "position", "in", "target", "tree", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1482-L1494
openstax/cnx-easybake
cnxeasybake/oven.py
insert_group
def insert_group(node, target): """Insert node into in target tree, in appropriate group. Uses group and lang from target function. This assumes the node and target share a structure of a first child that determines the grouping, and a second child that will be accumulated in the group. """ gr...
python
def insert_group(node, target): """Insert node into in target tree, in appropriate group. Uses group and lang from target function. This assumes the node and target share a structure of a first child that determines the grouping, and a second child that will be accumulated in the group. """ gr...
[ "def", "insert_group", "(", "node", ",", "target", ")", ":", "group", "=", "target", ".", "sort", "lang", "=", "target", ".", "lang", "collator", "=", "Collator", ".", "createInstance", "(", "Locale", "(", "lang", ")", "if", "lang", "else", "Locale", "...
Insert node into in target tree, in appropriate group. Uses group and lang from target function. This assumes the node and target share a structure of a first child that determines the grouping, and a second child that will be accumulated in the group.
[ "Insert", "node", "into", "in", "target", "tree", "in", "appropriate", "group", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1497-L1518
openstax/cnx-easybake
cnxeasybake/oven.py
create_group
def create_group(value): """Create the group wrapper node.""" node = etree.Element('div', attrib={'class': 'group-by'}) span = etree.Element('span', attrib={'class': 'group-label'}) span.text = value node.append(span) return node
python
def create_group(value): """Create the group wrapper node.""" node = etree.Element('div', attrib={'class': 'group-by'}) span = etree.Element('span', attrib={'class': 'group-label'}) span.text = value node.append(span) return node
[ "def", "create_group", "(", "value", ")", ":", "node", "=", "etree", ".", "Element", "(", "'div'", ",", "attrib", "=", "{", "'class'", ":", "'group-by'", "}", ")", "span", "=", "etree", ".", "Element", "(", "'span'", ",", "attrib", "=", "{", "'class'...
Create the group wrapper node.
[ "Create", "the", "group", "wrapper", "node", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1521-L1527
openstax/cnx-easybake
cnxeasybake/oven.py
_extract_sel_info
def _extract_sel_info(sel): """Recurse down parsed tree, return pseudo class info""" from cssselect2.parser import (CombinedSelector, CompoundSelector, PseudoClassSelector, FunctionalPseudoClassSelector) steps = [] extras = [] if ...
python
def _extract_sel_info(sel): """Recurse down parsed tree, return pseudo class info""" from cssselect2.parser import (CombinedSelector, CompoundSelector, PseudoClassSelector, FunctionalPseudoClassSelector) steps = [] extras = [] if ...
[ "def", "_extract_sel_info", "(", "sel", ")", ":", "from", "cssselect2", ".", "parser", "import", "(", "CombinedSelector", ",", "CompoundSelector", ",", "PseudoClassSelector", ",", "FunctionalPseudoClassSelector", ")", "steps", "=", "[", "]", "extras", "=", "[", ...
Recurse down parsed tree, return pseudo class info
[ "Recurse", "down", "parsed", "tree", "return", "pseudo", "class", "info" ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1530-L1553
openstax/cnx-easybake
cnxeasybake/oven.py
extract_selector_info
def extract_selector_info(sel): """Return selector special pseudo class info (steps and other).""" # walk the parsed_tree, looking for pseudoClass selectors, check names # add in steps and/or deferred extras steps, extras = _extract_sel_info(sel.parsed_tree) steps = sorted(set(steps)) extras = ...
python
def extract_selector_info(sel): """Return selector special pseudo class info (steps and other).""" # walk the parsed_tree, looking for pseudoClass selectors, check names # add in steps and/or deferred extras steps, extras = _extract_sel_info(sel.parsed_tree) steps = sorted(set(steps)) extras = ...
[ "def", "extract_selector_info", "(", "sel", ")", ":", "# walk the parsed_tree, looking for pseudoClass selectors, check names", "# add in steps and/or deferred extras", "steps", ",", "extras", "=", "_extract_sel_info", "(", "sel", ".", "parsed_tree", ")", "steps", "=", "sort...
Return selector special pseudo class info (steps and other).
[ "Return", "selector", "special", "pseudo", "class", "info", "(", "steps", "and", "other", ")", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1556-L1565
openstax/cnx-easybake
cnxeasybake/oven.py
_to_roman
def _to_roman(num): """Convert integer to roman numerals.""" roman_numeral_map = ( ('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5), ...
python
def _to_roman(num): """Convert integer to roman numerals.""" roman_numeral_map = ( ('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5), ...
[ "def", "_to_roman", "(", "num", ")", ":", "roman_numeral_map", "=", "(", "(", "'M'", ",", "1000", ")", ",", "(", "'CM'", ",", "900", ")", ",", "(", "'D'", ",", "500", ")", ",", "(", "'CD'", ",", "400", ")", ",", "(", "'C'", ",", "100", ")", ...
Convert integer to roman numerals.
[ "Convert", "integer", "to", "roman", "numerals", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1570-L1595
openstax/cnx-easybake
cnxeasybake/oven.py
copy_w_id_suffix
def copy_w_id_suffix(elem, suffix="_copy"): """Make a deep copy of the provided tree, altering ids.""" mycopy = deepcopy(elem) for id_elem in mycopy.xpath('//*[@id]'): id_elem.set('id', id_elem.get('id') + suffix) return mycopy
python
def copy_w_id_suffix(elem, suffix="_copy"): """Make a deep copy of the provided tree, altering ids.""" mycopy = deepcopy(elem) for id_elem in mycopy.xpath('//*[@id]'): id_elem.set('id', id_elem.get('id') + suffix) return mycopy
[ "def", "copy_w_id_suffix", "(", "elem", ",", "suffix", "=", "\"_copy\"", ")", ":", "mycopy", "=", "deepcopy", "(", "elem", ")", "for", "id_elem", "in", "mycopy", ".", "xpath", "(", "'//*[@id]'", ")", ":", "id_elem", ".", "set", "(", "'id'", ",", "id_el...
Make a deep copy of the provided tree, altering ids.
[ "Make", "a", "deep", "copy", "of", "the", "provided", "tree", "altering", "ids", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1598-L1603
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.generate_id
def generate_id(self): """Generate a fresh id""" if self.use_repeatable_ids: self.repeatable_id_counter += 1 return 'autobaked-{}'.format(self.repeatable_id_counter) else: return str(uuid4())
python
def generate_id(self): """Generate a fresh id""" if self.use_repeatable_ids: self.repeatable_id_counter += 1 return 'autobaked-{}'.format(self.repeatable_id_counter) else: return str(uuid4())
[ "def", "generate_id", "(", "self", ")", ":", "if", "self", ".", "use_repeatable_ids", ":", "self", ".", "repeatable_id_counter", "+=", "1", "return", "'autobaked-{}'", ".", "format", "(", "self", ".", "repeatable_id_counter", ")", "else", ":", "return", "str",...
Generate a fresh id
[ "Generate", "a", "fresh", "id" ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L152-L158
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.clear_state
def clear_state(self): """Clear the recipe state.""" self.state = {} self.state['steps'] = [] self.state['current_step'] = None self.state['scope'] = [] self.state['counters'] = {} self.state['strings'] = {} for step in self.matchers: self.stat...
python
def clear_state(self): """Clear the recipe state.""" self.state = {} self.state['steps'] = [] self.state['current_step'] = None self.state['scope'] = [] self.state['counters'] = {} self.state['strings'] = {} for step in self.matchers: self.stat...
[ "def", "clear_state", "(", "self", ")", ":", "self", ".", "state", "=", "{", "}", "self", ".", "state", "[", "'steps'", "]", "=", "[", "]", "self", ".", "state", "[", "'current_step'", "]", "=", "None", "self", ".", "state", "[", "'scope'", "]", ...
Clear the recipe state.
[ "Clear", "the", "recipe", "state", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L160-L175
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.update_css
def update_css(self, css_in=None, clear_css=False): """Add additional CSS rules, optionally replacing all.""" if clear_css: self.matchers = {} # CSS is changing, so clear processing state self.clear_state() if css_in is None: return try: ...
python
def update_css(self, css_in=None, clear_css=False): """Add additional CSS rules, optionally replacing all.""" if clear_css: self.matchers = {} # CSS is changing, so clear processing state self.clear_state() if css_in is None: return try: ...
[ "def", "update_css", "(", "self", ",", "css_in", "=", "None", ",", "clear_css", "=", "False", ")", ":", "if", "clear_css", ":", "self", ".", "matchers", "=", "{", "}", "# CSS is changing, so clear processing state", "self", ".", "clear_state", "(", ")", "if"...
Add additional CSS rules, optionally replacing all.
[ "Add", "additional", "CSS", "rules", "optionally", "replacing", "all", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L177-L292
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.bake
def bake(self, element, last_step=None): """Apply recipes to HTML tree. Will build recipes if needed.""" if last_step is not None: try: self.state['steps'] = [s for s in self.state['steps'] if int(s) < int(last_step)] except...
python
def bake(self, element, last_step=None): """Apply recipes to HTML tree. Will build recipes if needed.""" if last_step is not None: try: self.state['steps'] = [s for s in self.state['steps'] if int(s) < int(last_step)] except...
[ "def", "bake", "(", "self", ",", "element", ",", "last_step", "=", "None", ")", ":", "if", "last_step", "is", "not", "None", ":", "try", ":", "self", ".", "state", "[", "'steps'", "]", "=", "[", "s", "for", "s", "in", "self", ".", "state", "[", ...
Apply recipes to HTML tree. Will build recipes if needed.
[ "Apply", "recipes", "to", "HTML", "tree", ".", "Will", "build", "recipes", "if", "needed", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L294-L382
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.record_coverage_zero
def record_coverage_zero(self, rule, offset): """Add entry to coverage saying this selector was parsed""" self.coverage_lines.append('DA:{},0'.format(rule.source_line + offset))
python
def record_coverage_zero(self, rule, offset): """Add entry to coverage saying this selector was parsed""" self.coverage_lines.append('DA:{},0'.format(rule.source_line + offset))
[ "def", "record_coverage_zero", "(", "self", ",", "rule", ",", "offset", ")", ":", "self", ".", "coverage_lines", ".", "append", "(", "'DA:{},0'", ".", "format", "(", "rule", ".", "source_line", "+", "offset", ")", ")" ]
Add entry to coverage saying this selector was parsed
[ "Add", "entry", "to", "coverage", "saying", "this", "selector", "was", "parsed" ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L384-L386
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.record_coverage
def record_coverage(self, rule): """Add entry to coverage saying this selector was matched""" log(DEBUG, u'Rule ({}): {}'.format(*rule).encode('utf-8')) self.coverage_lines.append('DA:{},1'.format(rule[0]))
python
def record_coverage(self, rule): """Add entry to coverage saying this selector was matched""" log(DEBUG, u'Rule ({}): {}'.format(*rule).encode('utf-8')) self.coverage_lines.append('DA:{},1'.format(rule[0]))
[ "def", "record_coverage", "(", "self", ",", "rule", ")", ":", "log", "(", "DEBUG", ",", "u'Rule ({}): {}'", ".", "format", "(", "*", "rule", ")", ".", "encode", "(", "'utf-8'", ")", ")", "self", ".", "coverage_lines", ".", "append", "(", "'DA:{},1'", "...
Add entry to coverage saying this selector was matched
[ "Add", "entry", "to", "coverage", "saying", "this", "selector", "was", "matched" ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L388-L391
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.build_recipe
def build_recipe(self, element, step, depth=0): """Construct a set of steps to collate (and number) an HTML doc. Returns a state object that contains the steps to apply to the HTML tree. CSS rules match during a recusive descent HTML tree walk. Each declaration has a method that then ru...
python
def build_recipe(self, element, step, depth=0): """Construct a set of steps to collate (and number) an HTML doc. Returns a state object that contains the steps to apply to the HTML tree. CSS rules match during a recusive descent HTML tree walk. Each declaration has a method that then ru...
[ "def", "build_recipe", "(", "self", ",", "element", ",", "step", ",", "depth", "=", "0", ")", ":", "element_id", "=", "element", ".", "etree_element", ".", "get", "(", "'id'", ")", "self", ".", "state", "[", "'lang'", "]", "=", "element", ".", "lang"...
Construct a set of steps to collate (and number) an HTML doc. Returns a state object that contains the steps to apply to the HTML tree. CSS rules match during a recusive descent HTML tree walk. Each declaration has a method that then runs, given the current element, the decaration value...
[ "Construct", "a", "set", "of", "steps", "to", "collate", "(", "and", "number", ")", "an", "HTML", "doc", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L401-L576
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.push_target_elem
def push_target_elem(self, element, pseudo=None): """Place target element onto action stack.""" actions = self.state[self.state['current_step']]['actions'] if len(actions) > 0 and actions[-1][0] == 'target': actions.pop() actions.append(('target', Target(element.etree_element...
python
def push_target_elem(self, element, pseudo=None): """Place target element onto action stack.""" actions = self.state[self.state['current_step']]['actions'] if len(actions) > 0 and actions[-1][0] == 'target': actions.pop() actions.append(('target', Target(element.etree_element...
[ "def", "push_target_elem", "(", "self", ",", "element", ",", "pseudo", "=", "None", ")", ":", "actions", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'current_step'", "]", "]", "[", "'actions'", "]", "if", "len", "(", "actions", ")", "...
Place target element onto action stack.
[ "Place", "target", "element", "onto", "action", "stack", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L580-L587
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.push_pending_elem
def push_pending_elem(self, element, pseudo): """Create and place pending target element onto stack.""" self.push_target_elem(element, pseudo) elem = etree.Element('div') actions = self.state[self.state['current_step']]['actions'] actions.append(('move', elem)) actions.ap...
python
def push_pending_elem(self, element, pseudo): """Create and place pending target element onto stack.""" self.push_target_elem(element, pseudo) elem = etree.Element('div') actions = self.state[self.state['current_step']]['actions'] actions.append(('move', elem)) actions.ap...
[ "def", "push_pending_elem", "(", "self", ",", "element", ",", "pseudo", ")", ":", "self", ".", "push_target_elem", "(", "element", ",", "pseudo", ")", "elem", "=", "etree", ".", "Element", "(", "'div'", ")", "actions", "=", "self", ".", "state", "[", "...
Create and place pending target element onto stack.
[ "Create", "and", "place", "pending", "target", "element", "onto", "stack", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L589-L595
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.pop_pending_if_empty
def pop_pending_if_empty(self, element): """Remove empty wrapper element.""" actions = self.state[self.state['current_step']]['actions'] elem = self.current_target().tree if actions[-1][0] == ('target') and actions[-1][1].tree == elem: actions.pop() actions.pop() ...
python
def pop_pending_if_empty(self, element): """Remove empty wrapper element.""" actions = self.state[self.state['current_step']]['actions'] elem = self.current_target().tree if actions[-1][0] == ('target') and actions[-1][1].tree == elem: actions.pop() actions.pop() ...
[ "def", "pop_pending_if_empty", "(", "self", ",", "element", ")", ":", "actions", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'current_step'", "]", "]", "[", "'actions'", "]", "elem", "=", "self", ".", "current_target", "(", ")", ".", "t...
Remove empty wrapper element.
[ "Remove", "empty", "wrapper", "element", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L597-L604
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.current_target
def current_target(self): """Return current target.""" actions = self.state[self.state['current_step']]['actions'] for action, value in reversed(actions): if action == 'target': return value
python
def current_target(self): """Return current target.""" actions = self.state[self.state['current_step']]['actions'] for action, value in reversed(actions): if action == 'target': return value
[ "def", "current_target", "(", "self", ")", ":", "actions", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'current_step'", "]", "]", "[", "'actions'", "]", "for", "action", ",", "value", "in", "reversed", "(", "actions", ")", ":", "if", ...
Return current target.
[ "Return", "current", "target", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L606-L611
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.find_method
def find_method(self, decl): """Find class method to call for declaration based on name.""" name = decl.name method = None try: method = getattr(self, u'do_{}'.format( (name).replace('-', '_'))) except AttributeError: if name.s...
python
def find_method(self, decl): """Find class method to call for declaration based on name.""" name = decl.name method = None try: method = getattr(self, u'do_{}'.format( (name).replace('-', '_'))) except AttributeError: if name.s...
[ "def", "find_method", "(", "self", ",", "decl", ")", ":", "name", "=", "decl", ".", "name", "method", "=", "None", "try", ":", "method", "=", "getattr", "(", "self", ",", "u'do_{}'", ".", "format", "(", "(", "name", ")", ".", "replace", "(", "'-'",...
Find class method to call for declaration based on name.
[ "Find", "class", "method", "to", "call", "for", "declaration", "based", "on", "name", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L614-L633
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.lookup
def lookup(self, vtype, vname, target_id=None): """Return value of vname from the variable store vtype. Valid vtypes are `strings` 'counters', and `pending`. If the value is not found in the current steps store, earlier steps will be checked. If not found, '', 0, or (None, None) is retu...
python
def lookup(self, vtype, vname, target_id=None): """Return value of vname from the variable store vtype. Valid vtypes are `strings` 'counters', and `pending`. If the value is not found in the current steps store, earlier steps will be checked. If not found, '', 0, or (None, None) is retu...
[ "def", "lookup", "(", "self", ",", "vtype", ",", "vname", ",", "target_id", "=", "None", ")", ":", "nullvals", "=", "{", "'strings'", ":", "''", ",", "'counters'", ":", "0", ",", "'pending'", ":", "(", "None", ",", "None", ")", "}", "nullval", "=",...
Return value of vname from the variable store vtype. Valid vtypes are `strings` 'counters', and `pending`. If the value is not found in the current steps store, earlier steps will be checked. If not found, '', 0, or (None, None) is returned.
[ "Return", "value", "of", "vname", "from", "the", "variable", "store", "vtype", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L635-L675
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.counter_style
def counter_style(self, val, style): """Return counter value in given style.""" if style == 'decimal-leading-zero': if val < 10: valstr = "0{}".format(val) else: valstr = str(val) elif style == 'lower-roman': valstr = _to_roman(...
python
def counter_style(self, val, style): """Return counter value in given style.""" if style == 'decimal-leading-zero': if val < 10: valstr = "0{}".format(val) else: valstr = str(val) elif style == 'lower-roman': valstr = _to_roman(...
[ "def", "counter_style", "(", "self", ",", "val", ",", "style", ")", ":", "if", "style", "==", "'decimal-leading-zero'", ":", "if", "val", "<", "10", ":", "valstr", "=", "\"0{}\"", ".", "format", "(", "val", ")", "else", ":", "valstr", "=", "str", "("...
Return counter value in given style.
[ "Return", "counter", "value", "in", "given", "style", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L677-L707
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.eval_string_value
def eval_string_value(self, element, value): """Evaluate parsed string. Returns a list of current and delayed values. """ strval = '' vals = [] for term in value: if type(term) is ast.WhitespaceToken: pass elif type(term) is ast....
python
def eval_string_value(self, element, value): """Evaluate parsed string. Returns a list of current and delayed values. """ strval = '' vals = [] for term in value: if type(term) is ast.WhitespaceToken: pass elif type(term) is ast....
[ "def", "eval_string_value", "(", "self", ",", "element", ",", "value", ")", ":", "strval", "=", "''", "vals", "=", "[", "]", "for", "term", "in", "value", ":", "if", "type", "(", "term", ")", "is", "ast", ".", "WhitespaceToken", ":", "pass", "elif", ...
Evaluate parsed string. Returns a list of current and delayed values.
[ "Evaluate", "parsed", "string", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L709-L821
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.do_string_set
def do_string_set(self, element, decl, pseudo): """Implement string-set declaration.""" args = serialize(decl.value) step = self.state[self.state['current_step']] strval = '' strname = None for term in decl.value: if type(term) is ast.WhitespaceToken: ...
python
def do_string_set(self, element, decl, pseudo): """Implement string-set declaration.""" args = serialize(decl.value) step = self.state[self.state['current_step']] strval = '' strname = None for term in decl.value: if type(term) is ast.WhitespaceToken: ...
[ "def", "do_string_set", "(", "self", ",", "element", ",", "decl", ",", "pseudo", ")", ":", "args", "=", "serialize", "(", "decl", ".", "value", ")", "step", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'current_step'", "]", "]", "strva...
Implement string-set declaration.
[ "Implement", "string", "-", "set", "declaration", "." ]
train
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L824-L933