repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
openstack/swauth
swauth/middleware.py
Swauth.handle_prep
def handle_prep(self, req): """Handles the POST v2/.prep call for preparing the backing store Swift cluster for use with the auth subsystem. Can only be called by .super_admin. :param req: The swob.Request to process. :returns: swob.Response, 204 on success """ i...
python
def handle_prep(self, req): """Handles the POST v2/.prep call for preparing the backing store Swift cluster for use with the auth subsystem. Can only be called by .super_admin. :param req: The swob.Request to process. :returns: swob.Response, 204 on success """ i...
Handles the POST v2/.prep call for preparing the backing store Swift cluster for use with the auth subsystem. Can only be called by .super_admin. :param req: The swob.Request to process. :returns: swob.Response, 204 on success
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L588-L617
openstack/swauth
swauth/middleware.py
Swauth.handle_get_reseller
def handle_get_reseller(self, req): """Handles the GET v2 call for getting general reseller information (currently just a list of accounts). Can only be called by a .reseller_admin. On success, a JSON dictionary will be returned with a single `accounts` key whose value is list o...
python
def handle_get_reseller(self, req): """Handles the GET v2 call for getting general reseller information (currently just a list of accounts). Can only be called by a .reseller_admin. On success, a JSON dictionary will be returned with a single `accounts` key whose value is list o...
Handles the GET v2 call for getting general reseller information (currently just a list of accounts). Can only be called by a .reseller_admin. On success, a JSON dictionary will be returned with a single `accounts` key whose value is list of dicts. Each dict represents an account and ...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L619-L655
openstack/swauth
swauth/middleware.py
Swauth.handle_get_account
def handle_get_account(self, req): """Handles the GET v2/<account> call for getting account information. Can only be called by an account .admin. On success, a JSON dictionary will be returned containing the keys `account_id`, `services`, and `users`. The `account_id` is the value ...
python
def handle_get_account(self, req): """Handles the GET v2/<account> call for getting account information. Can only be called by an account .admin. On success, a JSON dictionary will be returned containing the keys `account_id`, `services`, and `users`. The `account_id` is the value ...
Handles the GET v2/<account> call for getting account information. Can only be called by an account .admin. On success, a JSON dictionary will be returned containing the keys `account_id`, `services`, and `users`. The `account_id` is the value used when creating service accounts. The `s...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L657-L714
openstack/swauth
swauth/middleware.py
Swauth.handle_set_services
def handle_set_services(self, req): """Handles the POST v2/<account>/.services call for setting services information. Can only be called by a reseller .admin. In the :func:`handle_get_account` (GET v2/<account>) call, a section of the returned JSON dict is `services`. This section looks...
python
def handle_set_services(self, req): """Handles the POST v2/<account>/.services call for setting services information. Can only be called by a reseller .admin. In the :func:`handle_get_account` (GET v2/<account>) call, a section of the returned JSON dict is `services`. This section looks...
Handles the POST v2/<account>/.services call for setting services information. Can only be called by a reseller .admin. In the :func:`handle_get_account` (GET v2/<account>) call, a section of the returned JSON dict is `services`. This section looks something like this:: "...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L716-L784
openstack/swauth
swauth/middleware.py
Swauth.handle_put_account
def handle_put_account(self, req): """Handles the PUT v2/<account> call for adding an account to the auth system. Can only be called by a .reseller_admin. By default, a newly created UUID4 will be used with the reseller prefix as the account id used when creating corresponding service a...
python
def handle_put_account(self, req): """Handles the PUT v2/<account> call for adding an account to the auth system. Can only be called by a .reseller_admin. By default, a newly created UUID4 will be used with the reseller prefix as the account id used when creating corresponding service a...
Handles the PUT v2/<account> call for adding an account to the auth system. Can only be called by a .reseller_admin. By default, a newly created UUID4 will be used with the reseller prefix as the account id used when creating corresponding service accounts. However, you can provide an X...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L786-L874
openstack/swauth
swauth/middleware.py
Swauth.handle_delete_account
def handle_delete_account(self, req): """Handles the DELETE v2/<account> call for removing an account from the auth system. Can only be called by a .reseller_admin. :param req: The swob.Request to process. :returns: swob.Response, 2xx on success. """ if not self.is_resel...
python
def handle_delete_account(self, req): """Handles the DELETE v2/<account> call for removing an account from the auth system. Can only be called by a .reseller_admin. :param req: The swob.Request to process. :returns: swob.Response, 2xx on success. """ if not self.is_resel...
Handles the DELETE v2/<account> call for removing an account from the auth system. Can only be called by a .reseller_admin. :param req: The swob.Request to process. :returns: swob.Response, 2xx on success.
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L876-L962
openstack/swauth
swauth/middleware.py
Swauth.handle_get_user
def handle_get_user(self, req): """Handles the GET v2/<account>/<user> call for getting user information. Can only be called by an account .admin. On success, a JSON dict will be returned as described:: {"groups": [ # List of groups the user is a member of {"name":...
python
def handle_get_user(self, req): """Handles the GET v2/<account>/<user> call for getting user information. Can only be called by an account .admin. On success, a JSON dict will be returned as described:: {"groups": [ # List of groups the user is a member of {"name":...
Handles the GET v2/<account>/<user> call for getting user information. Can only be called by an account .admin. On success, a JSON dict will be returned as described:: {"groups": [ # List of groups the user is a member of {"name": "<act>:<usr>"}, # The ...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L964-L1061
openstack/swauth
swauth/middleware.py
Swauth.handle_put_user
def handle_put_user(self, req): """Handles the PUT v2/<account>/<user> call for adding a user to an account. X-Auth-User-Key represents the user's key (url encoded), - OR - X-Auth-User-Key-Hash represents the user's hashed key (url encoded), X-Auth-User-Admin may be set ...
python
def handle_put_user(self, req): """Handles the PUT v2/<account>/<user> call for adding a user to an account. X-Auth-User-Key represents the user's key (url encoded), - OR - X-Auth-User-Key-Hash represents the user's hashed key (url encoded), X-Auth-User-Admin may be set ...
Handles the PUT v2/<account>/<user> call for adding a user to an account. X-Auth-User-Key represents the user's key (url encoded), - OR - X-Auth-User-Key-Hash represents the user's hashed key (url encoded), X-Auth-User-Admin may be set to `true` to create an account .admin, and ...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1063-L1145
openstack/swauth
swauth/middleware.py
Swauth.handle_delete_user
def handle_delete_user(self, req): """Handles the DELETE v2/<account>/<user> call for deleting a user from an account. Can only be called by an account .admin. :param req: The swob.Request to process. :returns: swob.Response, 2xx on success. """ # Validate path ...
python
def handle_delete_user(self, req): """Handles the DELETE v2/<account>/<user> call for deleting a user from an account. Can only be called by an account .admin. :param req: The swob.Request to process. :returns: swob.Response, 2xx on success. """ # Validate path ...
Handles the DELETE v2/<account>/<user> call for deleting a user from an account. Can only be called by an account .admin. :param req: The swob.Request to process. :returns: swob.Response, 2xx on success.
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1147-L1201
openstack/swauth
swauth/middleware.py
Swauth.is_user_reseller_admin
def is_user_reseller_admin(self, req, account, user): """Returns True if the user is a .reseller_admin. :param account: account user is part of :param user: the user :returns: True if user .reseller_admin, False if user is not a reseller_admin and None if the user ...
python
def is_user_reseller_admin(self, req, account, user): """Returns True if the user is a .reseller_admin. :param account: account user is part of :param user: the user :returns: True if user .reseller_admin, False if user is not a reseller_admin and None if the user ...
Returns True if the user is a .reseller_admin. :param account: account user is part of :param user: the user :returns: True if user .reseller_admin, False if user is not a reseller_admin and None if the user doesn't exist.
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1203-L1220
openstack/swauth
swauth/middleware.py
Swauth.handle_get_token
def handle_get_token(self, req): """Handles the various `request for token and service end point(s)` calls. There are various formats to support the various auth servers in the past. Examples:: GET <auth-prefix>/v1/<act>/auth X-Auth-User: <act>:<usr> or X-Storage-U...
python
def handle_get_token(self, req): """Handles the various `request for token and service end point(s)` calls. There are various formats to support the various auth servers in the past. Examples:: GET <auth-prefix>/v1/<act>/auth X-Auth-User: <act>:<usr> or X-Storage-U...
Handles the various `request for token and service end point(s)` calls. There are various formats to support the various auth servers in the past. Examples:: GET <auth-prefix>/v1/<act>/auth X-Auth-User: <act>:<usr> or X-Storage-User: <usr> X-Auth-Key: <key>...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1222-L1427
openstack/swauth
swauth/middleware.py
Swauth.handle_validate_token
def handle_validate_token(self, req): """Handles the GET v2/.token/<token> call for validating a token, usually called by a service like Swift. On a successful validation, X-Auth-TTL will be set for how much longer this token is valid and X-Auth-Groups will contain a comma separated ...
python
def handle_validate_token(self, req): """Handles the GET v2/.token/<token> call for validating a token, usually called by a service like Swift. On a successful validation, X-Auth-TTL will be set for how much longer this token is valid and X-Auth-Groups will contain a comma separated ...
Handles the GET v2/.token/<token> call for validating a token, usually called by a service like Swift. On a successful validation, X-Auth-TTL will be set for how much longer this token is valid and X-Auth-Groups will contain a comma separated list of groups the user belongs to. ...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1429-L1479
openstack/swauth
swauth/middleware.py
Swauth.get_conn
def get_conn(self, urlparsed=None): """Returns an HTTPConnection based on the urlparse result given or the default Swift cluster (internal url) urlparse result. :param urlparsed: The result from urlparse.urlparse or None to use the default Swift cluster's value ...
python
def get_conn(self, urlparsed=None): """Returns an HTTPConnection based on the urlparse result given or the default Swift cluster (internal url) urlparse result. :param urlparsed: The result from urlparse.urlparse or None to use the default Swift cluster's value ...
Returns an HTTPConnection based on the urlparse result given or the default Swift cluster (internal url) urlparse result. :param urlparsed: The result from urlparse.urlparse or None to use the default Swift cluster's value
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1481-L1493
openstack/swauth
swauth/middleware.py
Swauth.get_itoken
def get_itoken(self, env): """Returns the current internal token to use for the auth system's own actions with other services. Each process will create its own itoken and the token will be deleted and recreated based on the token_life configuration value. The itoken information is stored...
python
def get_itoken(self, env): """Returns the current internal token to use for the auth system's own actions with other services. Each process will create its own itoken and the token will be deleted and recreated based on the token_life configuration value. The itoken information is stored...
Returns the current internal token to use for the auth system's own actions with other services. Each process will create its own itoken and the token will be deleted and recreated based on the token_life configuration value. The itoken information is stored in memcache because the auth ...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1495-L1519
openstack/swauth
swauth/middleware.py
Swauth.get_admin_detail
def get_admin_detail(self, req): """Returns the dict for the user specified as the admin in the request with the addition of an `account` key set to the admin user's account. :param req: The swob request to retrieve X-Auth-Admin-User and X-Auth-Admin-Key from. :retur...
python
def get_admin_detail(self, req): """Returns the dict for the user specified as the admin in the request with the addition of an `account` key set to the admin user's account. :param req: The swob request to retrieve X-Auth-Admin-User and X-Auth-Admin-Key from. :retur...
Returns the dict for the user specified as the admin in the request with the addition of an `account` key set to the admin user's account. :param req: The swob request to retrieve X-Auth-Admin-User and X-Auth-Admin-Key from. :returns: The dict for the admin user with the add...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1521-L1539
openstack/swauth
swauth/middleware.py
Swauth.get_user_detail
def get_user_detail(self, req, account, user): """Returns the response body of a GET request for the specified user The body is in JSON format and contains all user information. :param req: The swob request :param account: the account the user is a member of :param user: the use...
python
def get_user_detail(self, req, account, user): """Returns the response body of a GET request for the specified user The body is in JSON format and contains all user information. :param req: The swob request :param account: the account the user is a member of :param user: the use...
Returns the response body of a GET request for the specified user The body is in JSON format and contains all user information. :param req: The swob request :param account: the account the user is a member of :param user: the user :returns: A JSON response with the user detail ...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1541-L1560
openstack/swauth
swauth/middleware.py
Swauth.credentials_match
def credentials_match(self, user_detail, key): """Returns True if the key is valid for the user_detail. It will use auth_encoder type the password was encoded with, to check for a key match. :param user_detail: The dict for the user. :param key: The key to validate for the user....
python
def credentials_match(self, user_detail, key): """Returns True if the key is valid for the user_detail. It will use auth_encoder type the password was encoded with, to check for a key match. :param user_detail: The dict for the user. :param key: The key to validate for the user....
Returns True if the key is valid for the user_detail. It will use auth_encoder type the password was encoded with, to check for a key match. :param user_detail: The dict for the user. :param key: The key to validate for the user. :returns: True if the key is valid for the user, ...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1562-L1579
openstack/swauth
swauth/middleware.py
Swauth.is_user_changing_own_key
def is_user_changing_own_key(self, req, user): """Check if the user is changing his own key. :param req: The swob.Request to check. This contains x-auth-admin-user and x-auth-admin-key headers which are credentials of the user sending the request. :param ...
python
def is_user_changing_own_key(self, req, user): """Check if the user is changing his own key. :param req: The swob.Request to check. This contains x-auth-admin-user and x-auth-admin-key headers which are credentials of the user sending the request. :param ...
Check if the user is changing his own key. :param req: The swob.Request to check. This contains x-auth-admin-user and x-auth-admin-key headers which are credentials of the user sending the request. :param user: User whose password is to be changed. :retur...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1581-L1609
openstack/swauth
swauth/middleware.py
Swauth.is_super_admin
def is_super_admin(self, req): """Returns True if the admin specified in the request represents the .super_admin. :param req: The swob.Request to check. :param returns: True if .super_admin. """ return req.headers.get('x-auth-admin-user') == '.super_admin' and \ ...
python
def is_super_admin(self, req): """Returns True if the admin specified in the request represents the .super_admin. :param req: The swob.Request to check. :param returns: True if .super_admin. """ return req.headers.get('x-auth-admin-user') == '.super_admin' and \ ...
Returns True if the admin specified in the request represents the .super_admin. :param req: The swob.Request to check. :param returns: True if .super_admin.
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1611-L1620
openstack/swauth
swauth/middleware.py
Swauth.is_reseller_admin
def is_reseller_admin(self, req, admin_detail=None): """Returns True if the admin specified in the request represents a .reseller_admin. :param req: The swob.Request to check. :param admin_detail: The previously retrieved dict from :func:`get_admin_detail` o...
python
def is_reseller_admin(self, req, admin_detail=None): """Returns True if the admin specified in the request represents a .reseller_admin. :param req: The swob.Request to check. :param admin_detail: The previously retrieved dict from :func:`get_admin_detail` o...
Returns True if the admin specified in the request represents a .reseller_admin. :param req: The swob.Request to check. :param admin_detail: The previously retrieved dict from :func:`get_admin_detail` or None for this function to retriev...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/middleware.py#L1622-L1641
openstack/swauth
swauth/authtypes.py
validate_creds
def validate_creds(creds): """Parse and validate user credentials whether format is right :param creds: User credentials :returns: Auth_type class instance and parsed user credentials in dict :raises ValueError: If credential format is wrong (eg: bad auth_type) """ try: auth_type, auth_...
python
def validate_creds(creds): """Parse and validate user credentials whether format is right :param creds: User credentials :returns: Auth_type class instance and parsed user credentials in dict :raises ValueError: If credential format is wrong (eg: bad auth_type) """ try: auth_type, auth_...
Parse and validate user credentials whether format is right :param creds: User credentials :returns: Auth_type class instance and parsed user credentials in dict :raises ValueError: If credential format is wrong (eg: bad auth_type)
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/authtypes.py#L42-L60
openstack/swauth
swauth/authtypes.py
Sha1.encode_w_salt
def encode_w_salt(self, salt, key): """Encodes a user key with salt into a particular format. The result of this method will be used internally. :param salt: Salt for hashing :param key: User's secret key :returns: A string representing user credentials """ enc_k...
python
def encode_w_salt(self, salt, key): """Encodes a user key with salt into a particular format. The result of this method will be used internally. :param salt: Salt for hashing :param key: User's secret key :returns: A string representing user credentials """ enc_k...
Encodes a user key with salt into a particular format. The result of this method will be used internally. :param salt: Salt for hashing :param key: User's secret key :returns: A string representing user credentials
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/authtypes.py#L112-L122
openstack/swauth
swauth/authtypes.py
Sha1.encode
def encode(self, key): """Encodes a user key into a particular format. The result of this method will be used by swauth for storing user credentials. If salt is not manually set in conf file, a random salt will be generated and used. :param key: User's secret key :retur...
python
def encode(self, key): """Encodes a user key into a particular format. The result of this method will be used by swauth for storing user credentials. If salt is not manually set in conf file, a random salt will be generated and used. :param key: User's secret key :retur...
Encodes a user key into a particular format. The result of this method will be used by swauth for storing user credentials. If salt is not manually set in conf file, a random salt will be generated and used. :param key: User's secret key :returns: A string representing user cre...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/authtypes.py#L124-L135
openstack/swauth
swauth/authtypes.py
Sha1.match
def match(self, key, creds, salt, **kwargs): """Checks whether the user-provided key matches the user's credentials :param key: User-supplied key :param creds: User's stored credentials :param salt: Salt for hashing :param kwargs: Extra keyword args for compatibility reason with...
python
def match(self, key, creds, salt, **kwargs): """Checks whether the user-provided key matches the user's credentials :param key: User-supplied key :param creds: User's stored credentials :param salt: Salt for hashing :param kwargs: Extra keyword args for compatibility reason with...
Checks whether the user-provided key matches the user's credentials :param key: User-supplied key :param creds: User's stored credentials :param salt: Salt for hashing :param kwargs: Extra keyword args for compatibility reason with other auth_type classes ...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/authtypes.py#L137-L147
openstack/swauth
swauth/authtypes.py
Sha1.validate
def validate(self, auth_rest): """Validate user credentials whether format is right for Sha1 :param auth_rest: User credentials' part without auth_type :return: Dict with a hash and a salt part of user credentials :raises ValueError: If credentials' part doesn't contain delimiter ...
python
def validate(self, auth_rest): """Validate user credentials whether format is right for Sha1 :param auth_rest: User credentials' part without auth_type :return: Dict with a hash and a salt part of user credentials :raises ValueError: If credentials' part doesn't contain delimiter ...
Validate user credentials whether format is right for Sha1 :param auth_rest: User credentials' part without auth_type :return: Dict with a hash and a salt part of user credentials :raises ValueError: If credentials' part doesn't contain delimiter between a salt and a...
https://github.com/openstack/swauth/blob/0c8eaf50a9e2b3317f3eba62f205546904bc6d74/swauth/authtypes.py#L149-L169
oemof/demandlib
demandlib/bdew.py
ElecSlp.create_bdew_load_profiles
def create_bdew_load_profiles(self, dt_index, slp_types, holidays=None): """Calculates the hourly electricity load profile in MWh/h of a region. """ # define file path of slp csv data file_path = os.path.join(self.datapath, 'selp_series.csv') # Read standard load profile series...
python
def create_bdew_load_profiles(self, dt_index, slp_types, holidays=None): """Calculates the hourly electricity load profile in MWh/h of a region. """ # define file path of slp csv data file_path = os.path.join(self.datapath, 'selp_series.csv') # Read standard load profile series...
Calculates the hourly electricity load profile in MWh/h of a region.
https://github.com/oemof/demandlib/blob/4b62d60e05cb06eb2590f9c5655c2cdebf494080/demandlib/bdew.py#L70-L116
oemof/demandlib
demandlib/bdew.py
ElecSlp.get_profile
def get_profile(self, ann_el_demand_per_sector): """ Get the profiles for the given annual demand Parameters ---------- ann_el_demand_per_sector : dictionary Key: sector, value: annual value Returns ------- pandas.DataFrame : Table with all profiles ...
python
def get_profile(self, ann_el_demand_per_sector): """ Get the profiles for the given annual demand Parameters ---------- ann_el_demand_per_sector : dictionary Key: sector, value: annual value Returns ------- pandas.DataFrame : Table with all profiles ...
Get the profiles for the given annual demand Parameters ---------- ann_el_demand_per_sector : dictionary Key: sector, value: annual value Returns ------- pandas.DataFrame : Table with all profiles
https://github.com/oemof/demandlib/blob/4b62d60e05cb06eb2590f9c5655c2cdebf494080/demandlib/bdew.py#L118-L132
oemof/demandlib
demandlib/bdew.py
HeatBuilding.weighted_temperature
def weighted_temperature(self, how='geometric_series'): r""" A new temperature vector is generated containing a multi-day average temperature as needed in the load profile function. Parameters ---------- how : string string which type to return ("geometric_se...
python
def weighted_temperature(self, how='geometric_series'): r""" A new temperature vector is generated containing a multi-day average temperature as needed in the load profile function. Parameters ---------- how : string string which type to return ("geometric_se...
r""" A new temperature vector is generated containing a multi-day average temperature as needed in the load profile function. Parameters ---------- how : string string which type to return ("geometric_series" or "mean") Notes ----- Equation f...
https://github.com/oemof/demandlib/blob/4b62d60e05cb06eb2590f9c5655c2cdebf494080/demandlib/bdew.py#L178-L219
oemof/demandlib
demandlib/bdew.py
HeatBuilding.get_temperature_interval
def get_temperature_interval(self): """Appoints the corresponding temperature interval to each temperature in the temperature vector. """ intervals = ({ -20: 1, -19: 1, -18: 1, -17: 1, -16: 1, -15: 1, -14: 2, -13: 2, -12: 2, -11: 2, -10: 2, -9: 3, -8: 3, -7: 3, -6...
python
def get_temperature_interval(self): """Appoints the corresponding temperature interval to each temperature in the temperature vector. """ intervals = ({ -20: 1, -19: 1, -18: 1, -17: 1, -16: 1, -15: 1, -14: 2, -13: 2, -12: 2, -11: 2, -10: 2, -9: 3, -8: 3, -7: 3, -6...
Appoints the corresponding temperature interval to each temperature in the temperature vector.
https://github.com/oemof/demandlib/blob/4b62d60e05cb06eb2590f9c5655c2cdebf494080/demandlib/bdew.py#L221-L238
oemof/demandlib
demandlib/bdew.py
HeatBuilding.get_sf_values
def get_sf_values(self, filename='shlp_hour_factors.csv'): """ Determine the h-values Parameters ---------- filename : string name of file where sigmoid factors are stored """ file = os.path.join(self.datapath, filename) hour_factors = pd.read_csv(fil...
python
def get_sf_values(self, filename='shlp_hour_factors.csv'): """ Determine the h-values Parameters ---------- filename : string name of file where sigmoid factors are stored """ file = os.path.join(self.datapath, filename) hour_factors = pd.read_csv(fil...
Determine the h-values Parameters ---------- filename : string name of file where sigmoid factors are stored
https://github.com/oemof/demandlib/blob/4b62d60e05cb06eb2590f9c5655c2cdebf494080/demandlib/bdew.py#L240-L276
oemof/demandlib
demandlib/bdew.py
HeatBuilding.get_sigmoid_parameters
def get_sigmoid_parameters(self, filename='shlp_sigmoid_factors.csv'): """ Retrieve the sigmoid parameters from csv-files Parameters ---------- filename : string name of file where sigmoid factors are stored """ file = os.path.join(self.datapath, filename) ...
python
def get_sigmoid_parameters(self, filename='shlp_sigmoid_factors.csv'): """ Retrieve the sigmoid parameters from csv-files Parameters ---------- filename : string name of file where sigmoid factors are stored """ file = os.path.join(self.datapath, filename) ...
Retrieve the sigmoid parameters from csv-files Parameters ---------- filename : string name of file where sigmoid factors are stored
https://github.com/oemof/demandlib/blob/4b62d60e05cb06eb2590f9c5655c2cdebf494080/demandlib/bdew.py#L278-L301
oemof/demandlib
demandlib/bdew.py
HeatBuilding.get_weekday_parameters
def get_weekday_parameters(self, filename='shlp_weekday_factors.csv'): """ Retrieve the weekday parameter from csv-file Parameters ---------- filename : string name of file where sigmoid factors are stored """ file = os.path.join(self.datapath, filename) ...
python
def get_weekday_parameters(self, filename='shlp_weekday_factors.csv'): """ Retrieve the weekday parameter from csv-file Parameters ---------- filename : string name of file where sigmoid factors are stored """ file = os.path.join(self.datapath, filename) ...
Retrieve the weekday parameter from csv-file Parameters ---------- filename : string name of file where sigmoid factors are stored
https://github.com/oemof/demandlib/blob/4b62d60e05cb06eb2590f9c5655c2cdebf494080/demandlib/bdew.py#L303-L321
oemof/demandlib
demandlib/bdew.py
HeatBuilding.get_normalized_bdew_profile
def get_normalized_bdew_profile(self): """ Calculation of the normalized hourly heat demand """ self.df['temperature'] = self.temperature.values self.df['temperature_geo'] = self.weighted_temperature( how='geometric_series') sf = self.get_sf_values() [a, b, ...
python
def get_normalized_bdew_profile(self): """ Calculation of the normalized hourly heat demand """ self.df['temperature'] = self.temperature.values self.df['temperature_geo'] = self.weighted_temperature( how='geometric_series') sf = self.get_sf_values() [a, b, ...
Calculation of the normalized hourly heat demand
https://github.com/oemof/demandlib/blob/4b62d60e05cb06eb2590f9c5655c2cdebf494080/demandlib/bdew.py#L328-L344
chaosmail/python-fs
fs/fs.py
isfile
def isfile(path, **kwargs): """Check if *path* is a file""" import os.path return os.path.isfile(path, **kwargs)
python
def isfile(path, **kwargs): """Check if *path* is a file""" import os.path return os.path.isfile(path, **kwargs)
Check if *path* is a file
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L28-L31
chaosmail/python-fs
fs/fs.py
isdir
def isdir(path, **kwargs): """Check if *path* is a directory""" import os.path return os.path.isdir(path, **kwargs)
python
def isdir(path, **kwargs): """Check if *path* is a directory""" import os.path return os.path.isdir(path, **kwargs)
Check if *path* is a directory
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L33-L36
chaosmail/python-fs
fs/fs.py
rename
def rename(oldPath, newPath, **kwargs): """rename the file oldPath to newPath""" import os return os.rename(oldPath, newPath, **kwargs)
python
def rename(oldPath, newPath, **kwargs): """rename the file oldPath to newPath""" import os return os.rename(oldPath, newPath, **kwargs)
rename the file oldPath to newPath
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L38-L41
chaosmail/python-fs
fs/fs.py
chown
def chown(path, user=None, group=None): """change ownership of path""" import os import pwd import grp uid = pwd.getpwnam(user).pw_uid if user else -1 gid = grp.getgrnam(group).gr_gid if group else -1 return os.chown(path, uid, gid)
python
def chown(path, user=None, group=None): """change ownership of path""" import os import pwd import grp uid = pwd.getpwnam(user).pw_uid if user else -1 gid = grp.getgrnam(group).gr_gid if group else -1 return os.chown(path, uid, gid)
change ownership of path
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L59-L66
chaosmail/python-fs
fs/fs.py
chmod
def chmod(path, mode): """change pernmissions of path""" import os, stat st = os.stat(path) return os.chmod(path, mode)
python
def chmod(path, mode): """change pernmissions of path""" import os, stat st = os.stat(path) return os.chmod(path, mode)
change pernmissions of path
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L68-L72
chaosmail/python-fs
fs/fs.py
abspath
def abspath(path, **kwargs): """Return the absolute path of *path*""" import os.path return os.path.abspath(path, **kwargs)
python
def abspath(path, **kwargs): """Return the absolute path of *path*""" import os.path return os.path.abspath(path, **kwargs)
Return the absolute path of *path*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L105-L108
chaosmail/python-fs
fs/fs.py
normalize
def normalize(path, **kwargs): """Return the normalized path of *path*""" import os.path return os.path.normpath(path, **kwargs)
python
def normalize(path, **kwargs): """Return the normalized path of *path*""" import os.path return os.path.normpath(path, **kwargs)
Return the normalized path of *path*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L110-L113
chaosmail/python-fs
fs/fs.py
rmdir
def rmdir(path, recursive=True, **kwargs): """Remove the directory *path*""" if recursive: import shutil return shutil.rmtree(path, **kwargs) else: import os return os.remdir(path, **kwargs)
python
def rmdir(path, recursive=True, **kwargs): """Remove the directory *path*""" if recursive: import shutil return shutil.rmtree(path, **kwargs) else: import os return os.remdir(path, **kwargs)
Remove the directory *path*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L124-L131
chaosmail/python-fs
fs/fs.py
mkdir
def mkdir(path, recursive=True, **kwargs): """Unix equivalent *mkdir*""" import os if recursive: os.makedirs(path, **kwargs) else: os.mkdir(path, **kwargs)
python
def mkdir(path, recursive=True, **kwargs): """Unix equivalent *mkdir*""" import os if recursive: os.makedirs(path, **kwargs) else: os.mkdir(path, **kwargs)
Unix equivalent *mkdir*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L143-L149
chaosmail/python-fs
fs/fs.py
touch
def touch(path): """Unix equivalent *touch* @src: http://stackoverflow.com/a/1158096""" import os try: OPEN_FUNC(path, 'a+').close() except IOError: os.utime(path, None)
python
def touch(path): """Unix equivalent *touch* @src: http://stackoverflow.com/a/1158096""" import os try: OPEN_FUNC(path, 'a+').close() except IOError: os.utime(path, None)
Unix equivalent *touch* @src: http://stackoverflow.com/a/1158096
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L151-L158
chaosmail/python-fs
fs/fs.py
exists
def exists(path, **kwargs): """Check if file or directory exists""" import os.path return os.path.exists(path, **kwargs)
python
def exists(path, **kwargs): """Check if file or directory exists""" import os.path return os.path.exists(path, **kwargs)
Check if file or directory exists
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L160-L163
chaosmail/python-fs
fs/fs.py
list
def list(path='.'): """generator that returns all files of *path*""" import os for f in os.listdir(path): if isfile(join(path, f)): yield join(path, f) if path != '.' else f
python
def list(path='.'): """generator that returns all files of *path*""" import os for f in os.listdir(path): if isfile(join(path, f)): yield join(path, f) if path != '.' else f
generator that returns all files of *path*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L168-L173
chaosmail/python-fs
fs/fs.py
listdirs
def listdirs(path='.'): """generator that returns all directories of *path*""" import os for f in os.listdir(path): if isdir(join(path, f)): yield join(path, f) if path != '.' else f
python
def listdirs(path='.'): """generator that returns all directories of *path*""" import os for f in os.listdir(path): if isdir(join(path, f)): yield join(path, f) if path != '.' else f
generator that returns all directories of *path*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L175-L180
chaosmail/python-fs
fs/fs.py
find
def find(pattern, path='.', exclude=None, recursive=True): """Find files that match *pattern* in *path*""" import fnmatch import os if recursive: for root, dirnames, filenames in os.walk(path): for pat in _to_list(pattern): for filename in fnmatch.filter(filenames, p...
python
def find(pattern, path='.', exclude=None, recursive=True): """Find files that match *pattern* in *path*""" import fnmatch import os if recursive: for root, dirnames, filenames in os.walk(path): for pat in _to_list(pattern): for filename in fnmatch.filter(filenames, p...
Find files that match *pattern* in *path*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L182-L205
chaosmail/python-fs
fs/fs.py
finddirs
def finddirs(pattern, path='.', exclude=None, recursive=True): """Find directories that match *pattern* in *path*""" import fnmatch import os if recursive: for root, dirnames, filenames in os.walk(path): for pat in _to_list(pattern): for dirname in fnmatch.filter(dirn...
python
def finddirs(pattern, path='.', exclude=None, recursive=True): """Find directories that match *pattern* in *path*""" import fnmatch import os if recursive: for root, dirnames, filenames in os.walk(path): for pat in _to_list(pattern): for dirname in fnmatch.filter(dirn...
Find directories that match *pattern* in *path*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L207-L229
chaosmail/python-fs
fs/fs.py
write
def write(path, content, encoding="UTF-8", append=False, raw=False): """Write *content* to file *path*""" mode = 'wb' if not append else 'ab' with OPEN_FUNC(path, mode) as _file: if raw: import shutil shutil.copyfileobj(content, _file) else: _file.write(co...
python
def write(path, content, encoding="UTF-8", append=False, raw=False): """Write *content* to file *path*""" mode = 'wb' if not append else 'ab' with OPEN_FUNC(path, mode) as _file: if raw: import shutil shutil.copyfileobj(content, _file) else: _file.write(co...
Write *content* to file *path*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L235-L243
chaosmail/python-fs
fs/fs.py
read
def read(path, encoding="UTF-8"): """Read and return content from file *path*""" with OPEN_FUNC(path, 'rb') as _file: cont = _file.read() return cont.decode(encoding)
python
def read(path, encoding="UTF-8"): """Read and return content from file *path*""" with OPEN_FUNC(path, 'rb') as _file: cont = _file.read() return cont.decode(encoding)
Read and return content from file *path*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L245-L249
chaosmail/python-fs
fs/fs.py
get
def get(path): """Read an object from file""" try: import cPickle as pickle except: import pickle with open(path, 'rb') as file: return pickle.load(file)
python
def get(path): """Read an object from file""" try: import cPickle as pickle except: import pickle with open(path, 'rb') as file: return pickle.load(file)
Read an object from file
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L251-L259
chaosmail/python-fs
fs/fs.py
put
def put(path, obj): """Write an object to file""" try: import cPickle as pickle except: import pickle with open(path, 'wb') as file: return pickle.dump(obj, file)
python
def put(path, obj): """Write an object to file""" try: import cPickle as pickle except: import pickle with open(path, 'wb') as file: return pickle.dump(obj, file)
Write an object to file
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L261-L269
chaosmail/python-fs
fs/fs.py
join
def join(*args, **kwargs): """Join parts of a path together""" import os.path if _is_list(args[0]): return os.path.join(*args[0]) return os.path.join(*args, **kwargs)
python
def join(*args, **kwargs): """Join parts of a path together""" import os.path if _is_list(args[0]): return os.path.join(*args[0]) return os.path.join(*args, **kwargs)
Join parts of a path together
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L271-L276
chaosmail/python-fs
fs/fs.py
extname
def extname(path, **kwargs): """Return the extension from *path*""" import os.path name, ext = os.path.splitext(path, **kwargs) return ext
python
def extname(path, **kwargs): """Return the extension from *path*""" import os.path name, ext = os.path.splitext(path, **kwargs) return ext
Return the extension from *path*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L288-L292
chaosmail/python-fs
fs/fs.py
basename
def basename(path, ext=""): """Return the file base name from *path*""" import os.path if ext is False: return os.path.basename(path).replace(extname(path), "") else: return os.path.basename(path).replace(ext, "")
python
def basename(path, ext=""): """Return the file base name from *path*""" import os.path if ext is False: return os.path.basename(path).replace(extname(path), "") else: return os.path.basename(path).replace(ext, "")
Return the file base name from *path*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L294-L300
chaosmail/python-fs
fs/fs.py
add_suffix
def add_suffix(path, suffix=""): """Adds a suffix to a filename *path*""" return join(dirname(path), basename(path, ext=False) + suffix + extname(path))
python
def add_suffix(path, suffix=""): """Adds a suffix to a filename *path*""" return join(dirname(path), basename(path, ext=False) + suffix + extname(path))
Adds a suffix to a filename *path*
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L307-L309
chaosmail/python-fs
fs/fs.py
addpath
def addpath(path): """Add *path* to system path""" import sys if not exists(path): raise ValueError('Path %s does not exist' % path) sys.path.insert(1, path)
python
def addpath(path): """Add *path* to system path""" import sys if not exists(path): raise ValueError('Path %s does not exist' % path) sys.path.insert(1, path)
Add *path* to system path
https://github.com/chaosmail/python-fs/blob/2567922ced9387e327e65f3244caff3b7af35684/fs/fs.py#L315-L320
oemof/demandlib
demandlib/tools.py
add_weekdays2df
def add_weekdays2df(time_df, holidays=None, holiday_is_sunday=False): r"""Giving back a DataFrame containing weekdays and optionally holidays for the given year. Parameters ---------- time_df : pandas DataFrame DataFrame to which the weekdays should be added Optional Parameters --...
python
def add_weekdays2df(time_df, holidays=None, holiday_is_sunday=False): r"""Giving back a DataFrame containing weekdays and optionally holidays for the given year. Parameters ---------- time_df : pandas DataFrame DataFrame to which the weekdays should be added Optional Parameters --...
r"""Giving back a DataFrame containing weekdays and optionally holidays for the given year. Parameters ---------- time_df : pandas DataFrame DataFrame to which the weekdays should be added Optional Parameters ------------------- holidays : array with information for every hour of ...
https://github.com/oemof/demandlib/blob/4b62d60e05cb06eb2590f9c5655c2cdebf494080/demandlib/tools.py#L6-L44
oemof/demandlib
demandlib/particular_profiles.py
IndustrialLoadProfile.simple_profile
def simple_profile(self, annual_demand, **kwargs): """ Create industrial load profile Parameters ---------- annual_demand : float Total demand. Other Parameters ---------------- am : datetime.time beginning of workday pm :...
python
def simple_profile(self, annual_demand, **kwargs): """ Create industrial load profile Parameters ---------- annual_demand : float Total demand. Other Parameters ---------------- am : datetime.time beginning of workday pm :...
Create industrial load profile Parameters ---------- annual_demand : float Total demand. Other Parameters ---------------- am : datetime.time beginning of workday pm : datetime.time end of workday week : list ...
https://github.com/oemof/demandlib/blob/4b62d60e05cb06eb2590f9c5655c2cdebf494080/demandlib/particular_profiles.py#L20-L78
maaku/python-bitcoin
bitcoin/destination.py
BaseId.script
def script(self): """Returns a Script object representing a contract script portion of a payment to the destination.""" # The script object is cached, since constructing it may involve # a number of string-manipulation operations. if getattr(self, '_script', None) is None: ...
python
def script(self): """Returns a Script object representing a contract script portion of a payment to the destination.""" # The script object is cached, since constructing it may involve # a number of string-manipulation operations. if getattr(self, '_script', None) is None: ...
Returns a Script object representing a contract script portion of a payment to the destination.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/destination.py#L22-L29
maaku/python-bitcoin
bitcoin/tools.py
compress_amount
def compress_amount(n): """\ Compress 64-bit integer values, preferring a smaller size for whole numbers (base-10), so as to achieve run-length encoding gains on real- world data. The basic algorithm: * If the amount is 0, return 0 * Divide the amount (in base units) evenly by the larges...
python
def compress_amount(n): """\ Compress 64-bit integer values, preferring a smaller size for whole numbers (base-10), so as to achieve run-length encoding gains on real- world data. The basic algorithm: * If the amount is 0, return 0 * Divide the amount (in base units) evenly by the larges...
\ Compress 64-bit integer values, preferring a smaller size for whole numbers (base-10), so as to achieve run-length encoding gains on real- world data. The basic algorithm: * If the amount is 0, return 0 * Divide the amount (in base units) evenly by the largest power of 10 possibl...
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/tools.py#L34-L57
maaku/python-bitcoin
bitcoin/tools.py
decompress_amount
def decompress_amount(x): """\ Undo the value compression performed by x=compress_amount(n). The input x matches one of the following patterns: x = n = 0 x = 1+10*(9*n + d - 1) + e x = 1+10*(n - 1) + 9""" if not x: return 0; x = x - 1; # x = 10*(9*n + d - 1) + e x, e...
python
def decompress_amount(x): """\ Undo the value compression performed by x=compress_amount(n). The input x matches one of the following patterns: x = n = 0 x = 1+10*(9*n + d - 1) + e x = 1+10*(n - 1) + 9""" if not x: return 0; x = x - 1; # x = 10*(9*n + d - 1) + e x, e...
\ Undo the value compression performed by x=compress_amount(n). The input x matches one of the following patterns: x = n = 0 x = 1+10*(9*n + d - 1) + e x = 1+10*(n - 1) + 9
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/tools.py#L59-L80
maaku/python-bitcoin
bitcoin/tools.py
compact_from_target
def compact_from_target(target): """\ The “compact” format is a representation of a whole number N using an unsigned 32bit number similar to a floating point format. Conversion necessarily involves truncation if the target is greater than 2^23-1. The most significant 8 bits are the unsigned exponen...
python
def compact_from_target(target): """\ The “compact” format is a representation of a whole number N using an unsigned 32bit number similar to a floating point format. Conversion necessarily involves truncation if the target is greater than 2^23-1. The most significant 8 bits are the unsigned exponen...
\ The “compact” format is a representation of a whole number N using an unsigned 32bit number similar to a floating point format. Conversion necessarily involves truncation if the target is greater than 2^23-1. The most significant 8 bits are the unsigned exponent of base 256. This exponent can be ...
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/tools.py#L85-L122
maaku/python-bitcoin
bitcoin/tools.py
target_from_compact
def target_from_compact(bits): """\ Extract a full target from its compact representation, undoing the transformation x=compact_from_target(t). See compact_from_target() for more information on this 32-bit floating point format.""" size = bits >> 24 word = bits & 0x007fffff if size < 3: ...
python
def target_from_compact(bits): """\ Extract a full target from its compact representation, undoing the transformation x=compact_from_target(t). See compact_from_target() for more information on this 32-bit floating point format.""" size = bits >> 24 word = bits & 0x007fffff if size < 3: ...
\ Extract a full target from its compact representation, undoing the transformation x=compact_from_target(t). See compact_from_target() for more information on this 32-bit floating point format.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/tools.py#L124-L137
maaku/python-bitcoin
bitcoin/tools.py
icmp
def icmp(a, b): "Like cmp(), but for any iterator." for xa in a: try: xb = next(b) d = cmp(xa, xb) if d: return d except StopIteration: return 1 try: next(b) return -1 except StopIteration: return 0
python
def icmp(a, b): "Like cmp(), but for any iterator." for xa in a: try: xb = next(b) d = cmp(xa, xb) if d: return d except StopIteration: return 1 try: next(b) return -1 except StopIteration: return 0
Like cmp(), but for any iterator.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/tools.py#L145-L158
maaku/python-bitcoin
bitcoin/hash.py
_ChainedHashAlgorithm.copy
def copy(self): "Return a clone of this hash object." other = _ChainedHashAlgorithm(self._algorithms) other._hobj = deepcopy(self._hobj) other._fobj = deepcopy(self._fobj) return other
python
def copy(self): "Return a clone of this hash object." other = _ChainedHashAlgorithm(self._algorithms) other._hobj = deepcopy(self._hobj) other._fobj = deepcopy(self._fobj) return other
Return a clone of this hash object.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/hash.py#L89-L94
maaku/python-bitcoin
bitcoin/hash.py
_ChainedHashAlgorithm._finalize
def _finalize(self): "Computes _fobj, the completed hash." hobj = self._hobj for hashname in self._algorithms[1:]: fobj = hashlib.new(hashname) fobj.update(hobj.digest()) hobj = fobj self._fobj = hobj
python
def _finalize(self): "Computes _fobj, the completed hash." hobj = self._hobj for hashname in self._algorithms[1:]: fobj = hashlib.new(hashname) fobj.update(hobj.digest()) hobj = fobj self._fobj = hobj
Computes _fobj, the completed hash.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/hash.py#L96-L103
maaku/python-bitcoin
bitcoin/hash.py
_ChainedHashAlgorithm.update
def update(self, *args): "Appends any passed in byte arrays to the digest object." for string in args: self._hobj.update(string) self._fobj = None
python
def update(self, *args): "Appends any passed in byte arrays to the digest object." for string in args: self._hobj.update(string) self._fobj = None
Appends any passed in byte arrays to the digest object.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/hash.py#L118-L122
maaku/python-bitcoin
bitcoin/hash.py
_ChainedHashAlgorithm.digest_size
def digest_size(self): "Returns the size (in bytes) of the resulting digest." if getattr(self, '_fobj', None) is not None: return self._fobj.digest_size else: return hashlib.new(self._algorithms[-1]).digest_size
python
def digest_size(self): "Returns the size (in bytes) of the resulting digest." if getattr(self, '_fobj', None) is not None: return self._fobj.digest_size else: return hashlib.new(self._algorithms[-1]).digest_size
Returns the size (in bytes) of the resulting digest.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/hash.py#L132-L137
maaku/python-bitcoin
bitcoin/hash.py
_HashAlgorithmInterface.new
def new(self, string=None, *args, **kwargs): """Returns a `_ChainedHashAlgorithm` if the underlying tuple (specifying the list of algorithms) is not empty, otherwise a `_NopHashAlgorithm` instance is returned.""" if len(self): hobj = _ChainedHashAlgorithm(self, *args, **kwarg...
python
def new(self, string=None, *args, **kwargs): """Returns a `_ChainedHashAlgorithm` if the underlying tuple (specifying the list of algorithms) is not empty, otherwise a `_NopHashAlgorithm` instance is returned.""" if len(self): hobj = _ChainedHashAlgorithm(self, *args, **kwarg...
Returns a `_ChainedHashAlgorithm` if the underlying tuple (specifying the list of algorithms) is not empty, otherwise a `_NopHashAlgorithm` instance is returned.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/hash.py#L146-L156
maaku/python-bitcoin
bitcoin/authtree.py
BaseAuthTreeLink.count
def count(self): "The number of items, pruned or otherwise, contained by this branch." if getattr(self, '_count', None) is None: self._count = getattr(self.node, 'count', 0) return self._count
python
def count(self): "The number of items, pruned or otherwise, contained by this branch." if getattr(self, '_count', None) is None: self._count = getattr(self.node, 'count', 0) return self._count
The number of items, pruned or otherwise, contained by this branch.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/authtree.py#L61-L65
maaku/python-bitcoin
bitcoin/authtree.py
BaseAuthTreeLink.size
def size(self): "The canonical serialized size of this branch." if getattr(self, '_size', None) is None: self._size = getattr(self.node, 'size', 0) return self._size
python
def size(self): "The canonical serialized size of this branch." if getattr(self, '_size', None) is None: self._size = getattr(self.node, 'size', 0) return self._size
The canonical serialized size of this branch.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/authtree.py#L68-L72
maaku/python-bitcoin
bitcoin/authtree.py
BaseAuthTreeNode._forward_iterator
def _forward_iterator(self): "Returns a forward iterator over the trie" path = [(self, 0, Bits())] while path: node, idx, prefix = path.pop() if idx==0 and node.value is not None and not node.prune_value: yield (self._unpickle_key(prefix), self._unpickle_v...
python
def _forward_iterator(self): "Returns a forward iterator over the trie" path = [(self, 0, Bits())] while path: node, idx, prefix = path.pop() if idx==0 and node.value is not None and not node.prune_value: yield (self._unpickle_key(prefix), self._unpickle_v...
Returns a forward iterator over the trie
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/authtree.py#L429-L440
maaku/python-bitcoin
bitcoin/authtree.py
BaseAuthTreeNode._get_node_by_key
def _get_node_by_key(self, key, path=None): """Returns the 2-tuple (prefix, node) where node either contains the value corresponding to the key, or is the most specific prefix on the path which would contain the key if it were there. The key was found if prefix==key and the node.value is...
python
def _get_node_by_key(self, key, path=None): """Returns the 2-tuple (prefix, node) where node either contains the value corresponding to the key, or is the most specific prefix on the path which would contain the key if it were there. The key was found if prefix==key and the node.value is...
Returns the 2-tuple (prefix, node) where node either contains the value corresponding to the key, or is the most specific prefix on the path which would contain the key if it were there. The key was found if prefix==key and the node.value is not None.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/authtree.py#L504-L523
maaku/python-bitcoin
bitcoin/authtree.py
BaseAuthTreeNode.get
def get(self, key, value=None): "x.get(k[,d]) -> x[k] if k in x, else d. d defaults to None." _key = self._prepare_key(key) prefix, node = self._get_node_by_key(_key) if prefix==_key and node.value is not None: return self._unpickle_value(node.value) else: ...
python
def get(self, key, value=None): "x.get(k[,d]) -> x[k] if k in x, else d. d defaults to None." _key = self._prepare_key(key) prefix, node = self._get_node_by_key(_key) if prefix==_key and node.value is not None: return self._unpickle_value(node.value) else: ...
x.get(k[,d]) -> x[k] if k in x, else d. d defaults to None.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/authtree.py#L542-L549
maaku/python-bitcoin
bitcoin/authtree.py
BaseAuthTreeNode.update
def update(self, other=None, **kwargs): """x.update(E, **F) -> None. update x from trie/dict/iterable E or F. If E has a .keys() method, does: for k in E: x[k] = E[k] If E lacks .keys() method, does: for (k, v) in E: x[k] = v In either case, this is followed by: for k in F: x[k] ...
python
def update(self, other=None, **kwargs): """x.update(E, **F) -> None. update x from trie/dict/iterable E or F. If E has a .keys() method, does: for k in E: x[k] = E[k] If E lacks .keys() method, does: for (k, v) in E: x[k] = v In either case, this is followed by: for k in F: x[k] ...
x.update(E, **F) -> None. update x from trie/dict/iterable E or F. If E has a .keys() method, does: for k in E: x[k] = E[k] If E lacks .keys() method, does: for (k, v) in E: x[k] = v In either case, this is followed by: for k in F: x[k] = F[k]
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/authtree.py#L660-L676
maaku/python-bitcoin
bitcoin/authtree.py
BaseAuthTreeNode.trim
def trim(self, prefixes): "Prunes any keys beginning with the specified the specified prefixes." _prefixes, prefixes = set(map(lambda k:self._prepare_key(k), prefixes)), list() for t in lookahead(sorted(_prefixes)): if t[1] is not None: if t[0] == commonprefix(t): ...
python
def trim(self, prefixes): "Prunes any keys beginning with the specified the specified prefixes." _prefixes, prefixes = set(map(lambda k:self._prepare_key(k), prefixes)), list() for t in lookahead(sorted(_prefixes)): if t[1] is not None: if t[0] == commonprefix(t): ...
Prunes any keys beginning with the specified the specified prefixes.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/authtree.py#L736-L747
maaku/python-bitcoin
bitcoin/script.py
ScriptPickler.dump
def dump(self, script, file=None): "Write a compressed representation of script to the Pickler's file object." if file is None: file = self._file self._dump(script, file, self._protocol, self._version)
python
def dump(self, script, file=None): "Write a compressed representation of script to the Pickler's file object." if file is None: file = self._file self._dump(script, file, self._protocol, self._version)
Write a compressed representation of script to the Pickler's file object.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/script.py#L720-L724
maaku/python-bitcoin
bitcoin/script.py
ScriptPickler.dumps
def dumps(self, script): "Return a compressed representation of script as a binary string." string = BytesIO() self._dump(script, string, self._protocol, self._version) return string.getvalue()
python
def dumps(self, script): "Return a compressed representation of script as a binary string." string = BytesIO() self._dump(script, string, self._protocol, self._version) return string.getvalue()
Return a compressed representation of script as a binary string.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/script.py#L726-L730
maaku/python-bitcoin
bitcoin/script.py
ScriptPickler.load
def load(self, file=None): "Read and decompress a compact script from the Pickler's file object." if file is None: file = self._file script_class = self.get_script_class() script = self._load(file, self._protocol, self._version) return script_class(script)
python
def load(self, file=None): "Read and decompress a compact script from the Pickler's file object." if file is None: file = self._file script_class = self.get_script_class() script = self._load(file, self._protocol, self._version) return script_class(script)
Read and decompress a compact script from the Pickler's file object.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/script.py#L732-L738
maaku/python-bitcoin
bitcoin/script.py
ScriptPickler.loads
def loads(self, string): "Decompress the passed-in compact script and return the result." script_class = self.get_script_class() script = self._load(BytesIO(string), self._protocol, self._version) return script_class(script)
python
def loads(self, string): "Decompress the passed-in compact script and return the result." script_class = self.get_script_class() script = self._load(BytesIO(string), self._protocol, self._version) return script_class(script)
Decompress the passed-in compact script and return the result.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/script.py#L740-L744
maaku/python-bitcoin
bitcoin/merkle.py
_merkle_hash256
def _merkle_hash256(*args): """The default transform provided to merkle(), which calculates the hash of its parameters, serializes and joins them together, then performs a has256 of the resulting string. There are two special cases: no arguments, which results in 0, and a single argument, whose hash val...
python
def _merkle_hash256(*args): """The default transform provided to merkle(), which calculates the hash of its parameters, serializes and joins them together, then performs a has256 of the resulting string. There are two special cases: no arguments, which results in 0, and a single argument, whose hash val...
The default transform provided to merkle(), which calculates the hash of its parameters, serializes and joins them together, then performs a has256 of the resulting string. There are two special cases: no arguments, which results in 0, and a single argument, whose hash value is returned unmodified.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/merkle.py#L14-L40
maaku/python-bitcoin
bitcoin/merkle.py
merkle
def merkle(hashes, func=_merkle_hash256): """Convert an iterable of hashes or hashable objects into a binary tree, construct the interior values using a passed-in constructor or compression function, and return the root value of the tree. The default compressor is the hash256 function, resulting in root...
python
def merkle(hashes, func=_merkle_hash256): """Convert an iterable of hashes or hashable objects into a binary tree, construct the interior values using a passed-in constructor or compression function, and return the root value of the tree. The default compressor is the hash256 function, resulting in root...
Convert an iterable of hashes or hashable objects into a binary tree, construct the interior values using a passed-in constructor or compression function, and return the root value of the tree. The default compressor is the hash256 function, resulting in root-hash for the entire tree.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/merkle.py#L42-L76
maaku/python-bitcoin
bitcoin/merkle.py
MerkleNode.iteritems
def iteritems(self): "x.iteritems() -> an iterator over the (key, value) items of x in sorted order" left_is_hash = isinstance(self.left, numbers.Integral) right_is_hash = isinstance(self.right, numbers.Integral) if all([left_is_hash, right_is_hash]) or self.right is None: if...
python
def iteritems(self): "x.iteritems() -> an iterator over the (key, value) items of x in sorted order" left_is_hash = isinstance(self.left, numbers.Integral) right_is_hash = isinstance(self.right, numbers.Integral) if all([left_is_hash, right_is_hash]) or self.right is None: if...
x.iteritems() -> an iterator over the (key, value) items of x in sorted order
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/merkle.py#L230-L245
maaku/python-bitcoin
bitcoin/merkle.py
MerkleNode._get_by_index
def _get_by_index(self, index, path=None): """Returns the 2-tuple (node, idx) where node is either a terminal leaf node containing the value of that index in either it's left or right slot, or is the most specific node on the path which would contain the index if it were not pruned.""" ...
python
def _get_by_index(self, index, path=None): """Returns the 2-tuple (node, idx) where node is either a terminal leaf node containing the value of that index in either it's left or right slot, or is the most specific node on the path which would contain the index if it were not pruned.""" ...
Returns the 2-tuple (node, idx) where node is either a terminal leaf node containing the value of that index in either it's left or right slot, or is the most specific node on the path which would contain the index if it were not pruned.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/merkle.py#L301-L324
maaku/python-bitcoin
bitcoin/base58.py
b58encode
def b58encode(b, errors='strict'): "Encode bytes to a base58-encoded string." len_ = len(b) # Convert big-endian bytes to integer n = BigInteger.deserialize(BytesIO(b), len_) # Divide that integer into base58 res = [] while n > 0: n, r = divmod (n, 58) res.append(b58digits[...
python
def b58encode(b, errors='strict'): "Encode bytes to a base58-encoded string." len_ = len(b) # Convert big-endian bytes to integer n = BigInteger.deserialize(BytesIO(b), len_) # Divide that integer into base58 res = [] while n > 0: n, r = divmod (n, 58) res.append(b58digits[...
Encode bytes to a base58-encoded string.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/base58.py#L24-L43
maaku/python-bitcoin
bitcoin/base58.py
b58decode
def b58decode(s, errors='strict'): "Decode a base58-encoding string, returning bytes." if not s: return (b'', 0) # Convert the string to an integer n = 0 for c in s: n *= 58 if c not in b58digits: raise InvalidBase58Error(u"character %r is not a valid base58 " ...
python
def b58decode(s, errors='strict'): "Decode a base58-encoding string, returning bytes." if not s: return (b'', 0) # Convert the string to an integer n = 0 for c in s: n *= 58 if c not in b58digits: raise InvalidBase58Error(u"character %r is not a valid base58 " ...
Decode a base58-encoding string, returning bytes.
https://github.com/maaku/python-bitcoin/blob/1b80c284170fd3f547cc45f4700ce169f3f99641/bitcoin/base58.py#L45-L68
idlesign/torrentool
torrentool/cli.py
info
def info(torrent_path): """Print out information from .torrent file.""" my_torrent = Torrent.from_file(torrent_path) size = my_torrent.total_size click.secho('Name: %s' % my_torrent.name, fg='blue') click.secho('Files:') for file_tuple in my_torrent.files: click.secho(file_tuple.name)...
python
def info(torrent_path): """Print out information from .torrent file.""" my_torrent = Torrent.from_file(torrent_path) size = my_torrent.total_size click.secho('Name: %s' % my_torrent.name, fg='blue') click.secho('Files:') for file_tuple in my_torrent.files: click.secho(file_tuple.name)...
Print out information from .torrent file.
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/cli.py#L25-L39
idlesign/torrentool
torrentool/cli.py
create
def create(source, dest, tracker, open_trackers, comment, cache): """Create torrent file from a single file or a directory.""" source_title = path.basename(source).replace('.', '_').replace(' ', '_') dest = '%s.torrent' % path.join(dest, source_title) click.secho('Creating torrent from %s ...' % sourc...
python
def create(source, dest, tracker, open_trackers, comment, cache): """Create torrent file from a single file or a directory.""" source_title = path.basename(source).replace('.', '_').replace(' ', '_') dest = '%s.torrent' % path.join(dest, source_title) click.secho('Creating torrent from %s ...' % sourc...
Create torrent file from a single file or a directory.
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/cli.py#L49-L90
idlesign/torrentool
torrentool/torrent.py
Torrent.files
def files(self): """Files in torrent. List of namedtuples (filepath, size). :rtype: list[TorrentFile] """ files = [] info = self._struct.get('info') if not info: return files if 'files' in info: base = info['name'] ...
python
def files(self): """Files in torrent. List of namedtuples (filepath, size). :rtype: list[TorrentFile] """ files = [] info = self._struct.get('info') if not info: return files if 'files' in info: base = info['name'] ...
Files in torrent. List of namedtuples (filepath, size). :rtype: list[TorrentFile]
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/torrent.py#L108-L130
idlesign/torrentool
torrentool/torrent.py
Torrent.info_hash
def info_hash(self): """Hash of torrent file info section. Also known as torrent hash.""" info = self._struct.get('info') if not info: return None return sha1(Bencode.encode(info)).hexdigest()
python
def info_hash(self): """Hash of torrent file info section. Also known as torrent hash.""" info = self._struct.get('info') if not info: return None return sha1(Bencode.encode(info)).hexdigest()
Hash of torrent file info section. Also known as torrent hash.
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/torrent.py#L138-L145
idlesign/torrentool
torrentool/torrent.py
Torrent.announce_urls
def announce_urls(self): """List of lists of announce (tracker) URLs. First inner list is considered as primary announcers list, the following lists as back-ups. http://bittorrent.org/beps/bep_0012.html """ urls = self._struct.get('announce-list') if not urls:...
python
def announce_urls(self): """List of lists of announce (tracker) URLs. First inner list is considered as primary announcers list, the following lists as back-ups. http://bittorrent.org/beps/bep_0012.html """ urls = self._struct.get('announce-list') if not urls:...
List of lists of announce (tracker) URLs. First inner list is considered as primary announcers list, the following lists as back-ups. http://bittorrent.org/beps/bep_0012.html
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/torrent.py#L153-L170
idlesign/torrentool
torrentool/torrent.py
Torrent.get_magnet
def get_magnet(self, detailed=True): """Returns torrent magnet link, consisting of BTIH (BitTorrent Info Hash) URN anr optional other information. :param bool|list|tuple|set detailed: For boolean - whether additional info (such as trackers) should be included. For iterab...
python
def get_magnet(self, detailed=True): """Returns torrent magnet link, consisting of BTIH (BitTorrent Info Hash) URN anr optional other information. :param bool|list|tuple|set detailed: For boolean - whether additional info (such as trackers) should be included. For iterab...
Returns torrent magnet link, consisting of BTIH (BitTorrent Info Hash) URN anr optional other information. :param bool|list|tuple|set detailed: For boolean - whether additional info (such as trackers) should be included. For iterable - expected allowed parameter names: ...
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/torrent.py#L246-L298
idlesign/torrentool
torrentool/torrent.py
Torrent.to_file
def to_file(self, filepath=None): """Writes Torrent object into file, either :param filepath: """ if filepath is None and self._filepath is None: raise TorrentError('Unable to save torrent to file: no filepath supplied.') if filepath is not None: self._f...
python
def to_file(self, filepath=None): """Writes Torrent object into file, either :param filepath: """ if filepath is None and self._filepath is None: raise TorrentError('Unable to save torrent to file: no filepath supplied.') if filepath is not None: self._f...
Writes Torrent object into file, either :param filepath:
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/torrent.py#L300-L312
idlesign/torrentool
torrentool/torrent.py
Torrent.create_from
def create_from(cls, src_path): """Returns Torrent object created from a file or a directory. :param str src_path: :rtype: Torrent """ is_dir = isdir(src_path) target_files, size_data = cls._get_target_files_info(src_path) SIZE_MIN = 32768 # 32 KiB SIZE...
python
def create_from(cls, src_path): """Returns Torrent object created from a file or a directory. :param str src_path: :rtype: Torrent """ is_dir = isdir(src_path) target_files, size_data = cls._get_target_files_info(src_path) SIZE_MIN = 32768 # 32 KiB SIZE...
Returns Torrent object created from a file or a directory. :param str src_path: :rtype: Torrent
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/torrent.py#L348-L416
idlesign/torrentool
torrentool/torrent.py
Torrent.from_file
def from_file(cls, filepath): """Alternative constructor to get Torrent object from file. :param str filepath: :rtype: Torrent """ torrent = cls(Bencode.read_file(filepath)) torrent._filepath = filepath return torrent
python
def from_file(cls, filepath): """Alternative constructor to get Torrent object from file. :param str filepath: :rtype: Torrent """ torrent = cls(Bencode.read_file(filepath)) torrent._filepath = filepath return torrent
Alternative constructor to get Torrent object from file. :param str filepath: :rtype: Torrent
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/torrent.py#L428-L436
idlesign/torrentool
torrentool/utils.py
humanize_filesize
def humanize_filesize(bytes_size): """Returns human readable filesize. :param int bytes_size: :rtype: str """ if not bytes_size: return '0 B' names = ('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB') name_idx = int(math.floor(math.log(bytes_size, 1024))) size = round(b...
python
def humanize_filesize(bytes_size): """Returns human readable filesize. :param int bytes_size: :rtype: str """ if not bytes_size: return '0 B' names = ('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB') name_idx = int(math.floor(math.log(bytes_size, 1024))) size = round(b...
Returns human readable filesize. :param int bytes_size: :rtype: str
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/utils.py#L20-L34
idlesign/torrentool
torrentool/utils.py
upload_to_cache_server
def upload_to_cache_server(fpath): """Uploads .torrent file to a cache server. Returns upload file URL. :rtype: str """ url_base = 'http://torrage.info' url_upload = '%s/autoupload.php' % url_base url_download = '%s/torrent.php?h=' % url_base file_field = 'torrent' try: im...
python
def upload_to_cache_server(fpath): """Uploads .torrent file to a cache server. Returns upload file URL. :rtype: str """ url_base = 'http://torrage.info' url_upload = '%s/autoupload.php' % url_base url_download = '%s/torrent.php?h=' % url_base file_field = 'torrent' try: im...
Uploads .torrent file to a cache server. Returns upload file URL. :rtype: str
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/utils.py#L37-L61
idlesign/torrentool
torrentool/utils.py
get_open_trackers_from_remote
def get_open_trackers_from_remote(): """Returns open trackers announce URLs list from remote repo.""" url_base = 'https://raw.githubusercontent.com/idlesign/torrentool/master/torrentool/repo' url = '%s/%s' % (url_base, OPEN_TRACKERS_FILENAME) try: import requests response = requests.g...
python
def get_open_trackers_from_remote(): """Returns open trackers announce URLs list from remote repo.""" url_base = 'https://raw.githubusercontent.com/idlesign/torrentool/master/torrentool/repo' url = '%s/%s' % (url_base, OPEN_TRACKERS_FILENAME) try: import requests response = requests.g...
Returns open trackers announce URLs list from remote repo.
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/utils.py#L64-L83
idlesign/torrentool
torrentool/utils.py
get_open_trackers_from_local
def get_open_trackers_from_local(): """Returns open trackers announce URLs list from local backup.""" with open(path.join(path.dirname(__file__), 'repo', OPEN_TRACKERS_FILENAME)) as f: open_trackers = map(str.strip, f.readlines()) return list(open_trackers)
python
def get_open_trackers_from_local(): """Returns open trackers announce URLs list from local backup.""" with open(path.join(path.dirname(__file__), 'repo', OPEN_TRACKERS_FILENAME)) as f: open_trackers = map(str.strip, f.readlines()) return list(open_trackers)
Returns open trackers announce URLs list from local backup.
https://github.com/idlesign/torrentool/blob/78c474c2ecddbad2e3287b390ac8a043957f3563/torrentool/utils.py#L86-L91