Core¶
Note
This module contains functionality that isn’t useful to general users of the github2 package, but it is documented to aid contributors to the package.
- github2.core.NAIVE(bool) = True¶
Operate on naive datetime.datetime objects, this is the default for backwards compatibility
Set to False for timezone-aware datetime.datetime objects
- github2.core.GITHUB_TZ(datetime.tzinfo) = tzfile('/usr/share/zoneinfo/America/Los_Angeles')¶
Timezone used in output from GitHub API, currently defined as America/Los_Angeles in the Olson database
- github2.core.string_to_datetime(string)[source]¶
Convert a string to Python datetime.
Parameters: github_date (str) – date string to parse
- github2.core.datetime_to_ghdate(datetime_)[source]¶
Convert Python datetime to GitHub date string.
Parameters: datetime (datetime) – datetime object to convert Note
Supports naive and timezone-aware datetimes
- github2.core.datetime_to_commitdate(datetime_)[source]¶
Convert Python datetime to GitHub date string.
Parameters: datetime (datetime) – datetime object to convert Note
Supports naive and timezone-aware datetimes
- github2.core.datetime_to_isodate(datetime_)[source]¶
Convert Python datetime to GitHub date string.
Parameters: datetime (str) – datetime object to convert Note
Supports naive and timezone-aware datetimes
- github2.core.requires_auth(f)[source]¶
Decorate to check a function call for authentication.
Sets a requires_auth attribute on functions, for use in introspection.
Parameters: f (func) – Function to wrap Raises AuthError: If function called without an authenticated session
- github2.core.enhanced_by_auth(f)[source]¶
Decorator to mark a function as enhanced by authentication.
Sets a enhanced_by_auth attribute on functions, for use in introspection.
Parameters: f (func) – Function to wrap
- github2.core.doc_generator(docstring, attributes)[source]¶
Utility function to augment BaseDataType docstring.
Parameters:
- github2.core.repr_string(string)[source]¶
Shorten string for use in repr() output.
Parameters: string (str) – string to operate on Returns: string, with maximum length of 20 characters
- class github2.core.GithubCommand(request)[source]¶
Main API binding interface.
- get_value(*args, **kwargs)[source]¶
Process a single-value response from the API.
If a datatype parameter is given it defines the BaseData-derived class we should build from the provided data
- get_values(*args, **kwargs)[source]¶
Process a multi-value response from the API.
See : get_value()
- make_request(command, *args, **kwargs)[source]¶
Make an API request.
Various options are supported if they exist in kwargs:
- The value of a method argument will define the HTTP method to perform for this request, the default is GET
- The value of a filter argument will restrict the response to that data
- The value of a page argument will be used to fetch a specific page of results, default of 1 is assumed if not given