repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
scivision/pymap3d
pymap3d/ned.py
ned2geodetic
def ned2geodetic(n: float, e: float, d: float, lat0: float, lon0: float, h0: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ Converts North, East, Down to target latitude, longitude, altitude Parameters ---------- n : float or nu...
python
def ned2geodetic(n: float, e: float, d: float, lat0: float, lon0: float, h0: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ Converts North, East, Down to target latitude, longitude, altitude Parameters ---------- n : float or nu...
[ "def", "ned2geodetic", "(", "n", ":", "float", ",", "e", ":", "float", ",", "d", ":", "float", ",", "lat0", ":", "float", ",", "lon0", ":", "float", ",", "h0", ":", "float", ",", "ell", ":", "Ellipsoid", "=", "None", ",", "deg", ":", "bool", "=...
Converts North, East, Down to target latitude, longitude, altitude Parameters ---------- n : float or numpy.ndarray of float North NED coordinate (meters) e : float or numpy.ndarray of float East NED coordinate (meters) d : float or numpy.ndarray of float Down NED coordinat...
[ "Converts", "North", "East", "Down", "to", "target", "latitude", "longitude", "altitude" ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/ned.py#L68-L107
train
scivision/pymap3d
pymap3d/ned.py
ned2ecef
def ned2ecef(n: float, e: float, d: float, lat0: float, lon0: float, h0: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ North, East, Down to target ECEF coordinates Parameters ---------- n : float or numpy.ndarray of float North...
python
def ned2ecef(n: float, e: float, d: float, lat0: float, lon0: float, h0: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ North, East, Down to target ECEF coordinates Parameters ---------- n : float or numpy.ndarray of float North...
[ "def", "ned2ecef", "(", "n", ":", "float", ",", "e", ":", "float", ",", "d", ":", "float", ",", "lat0", ":", "float", ",", "lon0", ":", "float", ",", "h0", ":", "float", ",", "ell", ":", "Ellipsoid", "=", "None", ",", "deg", ":", "bool", "=", ...
North, East, Down to target ECEF coordinates Parameters ---------- n : float or numpy.ndarray of float North NED coordinate (meters) e : float or numpy.ndarray of float East NED coordinate (meters) d : float or numpy.ndarray of float Down NED coordinate (meters) lat0 : ...
[ "North", "East", "Down", "to", "target", "ECEF", "coordinates" ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/ned.py#L110-L146
train
scivision/pymap3d
pymap3d/ned.py
ecef2ned
def ecef2ned(x: float, y: float, z: float, lat0: float, lon0: float, h0: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ Convert ECEF x,y,z to North, East, Down Parameters ---------- x : float or numpy.ndarray of float ECEF x coo...
python
def ecef2ned(x: float, y: float, z: float, lat0: float, lon0: float, h0: float, ell: Ellipsoid = None, deg: bool = True) -> Tuple[float, float, float]: """ Convert ECEF x,y,z to North, East, Down Parameters ---------- x : float or numpy.ndarray of float ECEF x coo...
[ "def", "ecef2ned", "(", "x", ":", "float", ",", "y", ":", "float", ",", "z", ":", "float", ",", "lat0", ":", "float", ",", "lon0", ":", "float", ",", "h0", ":", "float", ",", "ell", ":", "Ellipsoid", "=", "None", ",", "deg", ":", "bool", "=", ...
Convert ECEF x,y,z to North, East, Down Parameters ---------- x : float or numpy.ndarray of float ECEF x coordinate (meters) y : float or numpy.ndarray of float ECEF y coordinate (meters) z : float or numpy.ndarray of float ECEF z coordinate (meters) lat0 : float ...
[ "Convert", "ECEF", "x", "y", "z", "to", "North", "East", "Down" ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/ned.py#L149-L188
train
scivision/pymap3d
pymap3d/ned.py
ecef2nedv
def ecef2nedv(x: float, y: float, z: float, lat0: float, lon0: float, deg: bool = True) -> Tuple[float, float, float]: """ for VECTOR between two points Parameters ---------- x : float or numpy.ndarray of float ECEF x coordinate (meters) y : float or numpy.nd...
python
def ecef2nedv(x: float, y: float, z: float, lat0: float, lon0: float, deg: bool = True) -> Tuple[float, float, float]: """ for VECTOR between two points Parameters ---------- x : float or numpy.ndarray of float ECEF x coordinate (meters) y : float or numpy.nd...
[ "def", "ecef2nedv", "(", "x", ":", "float", ",", "y", ":", "float", ",", "z", ":", "float", ",", "lat0", ":", "float", ",", "lon0", ":", "float", ",", "deg", ":", "bool", "=", "True", ")", "->", "Tuple", "[", "float", ",", "float", ",", "float"...
for VECTOR between two points Parameters ---------- x : float or numpy.ndarray of float ECEF x coordinate (meters) y : float or numpy.ndarray of float ECEF y coordinate (meters) z : float or numpy.ndarray of float ECEF z coordinate (meters) lat0 : float Observer ...
[ "for", "VECTOR", "between", "two", "points" ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/ned.py#L233-L268
train
scivision/pymap3d
pymap3d/vallado.py
azel2radec
def azel2radec(az_deg: float, el_deg: float, lat_deg: float, lon_deg: float, time: datetime) -> Tuple[float, float]: """ converts azimuth, elevation to right ascension, declination Parameters ---------- az_deg : float or numpy.ndarray of float azimuth (clockwi...
python
def azel2radec(az_deg: float, el_deg: float, lat_deg: float, lon_deg: float, time: datetime) -> Tuple[float, float]: """ converts azimuth, elevation to right ascension, declination Parameters ---------- az_deg : float or numpy.ndarray of float azimuth (clockwi...
[ "def", "azel2radec", "(", "az_deg", ":", "float", ",", "el_deg", ":", "float", ",", "lat_deg", ":", "float", ",", "lon_deg", ":", "float", ",", "time", ":", "datetime", ")", "->", "Tuple", "[", "float", ",", "float", "]", ":", "az", "=", "atleast_1d"...
converts azimuth, elevation to right ascension, declination Parameters ---------- az_deg : float or numpy.ndarray of float azimuth (clockwise) to point [degrees] el_deg : float or numpy.ndarray of float elevation above horizon to point [degrees] lat_deg : float observer W...
[ "converts", "azimuth", "elevation", "to", "right", "ascension", "declination" ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/vallado.py#L19-L80
train
scivision/pymap3d
pymap3d/vallado.py
radec2azel
def radec2azel(ra_deg: float, dec_deg: float, lat_deg: float, lon_deg: float, time: datetime) -> Tuple[float, float]: """ converts right ascension, declination to azimuth, elevation Parameters ---------- ra_deg : float or numpy.ndarray of float right ascension...
python
def radec2azel(ra_deg: float, dec_deg: float, lat_deg: float, lon_deg: float, time: datetime) -> Tuple[float, float]: """ converts right ascension, declination to azimuth, elevation Parameters ---------- ra_deg : float or numpy.ndarray of float right ascension...
[ "def", "radec2azel", "(", "ra_deg", ":", "float", ",", "dec_deg", ":", "float", ",", "lat_deg", ":", "float", ",", "lon_deg", ":", "float", ",", "time", ":", "datetime", ")", "->", "Tuple", "[", "float", ",", "float", "]", ":", "ra", "=", "atleast_1d...
converts right ascension, declination to azimuth, elevation Parameters ---------- ra_deg : float or numpy.ndarray of float right ascension to target [degrees] dec_deg : float or numpy.ndarray of float declination to target [degrees] lat_deg : float observer WGS84 latitude...
[ "converts", "right", "ascension", "declination", "to", "azimuth", "elevation" ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/vallado.py#L83-L146
train
scivision/pymap3d
pymap3d/aer.py
ecef2aer
def ecef2aer(x: float, y: float, z: float, lat0: float, lon0: float, h0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ gives azimuth, elevation and slant range from an Observer to a Point with ECEF coordinates. ECEF input location is with units of meters ...
python
def ecef2aer(x: float, y: float, z: float, lat0: float, lon0: float, h0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ gives azimuth, elevation and slant range from an Observer to a Point with ECEF coordinates. ECEF input location is with units of meters ...
[ "def", "ecef2aer", "(", "x", ":", "float", ",", "y", ":", "float", ",", "z", ":", "float", ",", "lat0", ":", "float", ",", "lon0", ":", "float", ",", "h0", ":", "float", ",", "ell", "=", "None", ",", "deg", ":", "bool", "=", "True", ")", "->"...
gives azimuth, elevation and slant range from an Observer to a Point with ECEF coordinates. ECEF input location is with units of meters Parameters ---------- x : float or numpy.ndarray of float ECEF x coordinate (meters) y : float or numpy.ndarray of float ECEF y coordinate (meter...
[ "gives", "azimuth", "elevation", "and", "slant", "range", "from", "an", "Observer", "to", "a", "Point", "with", "ECEF", "coordinates", "." ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/aer.py#L10-L49
train
scivision/pymap3d
pymap3d/aer.py
geodetic2aer
def geodetic2aer(lat: float, lon: float, h: float, lat0: float, lon0: float, h0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ gives azimuth, elevation and slant range from an Observer to a Point with geodetic coordinates. Parameters ----------...
python
def geodetic2aer(lat: float, lon: float, h: float, lat0: float, lon0: float, h0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ gives azimuth, elevation and slant range from an Observer to a Point with geodetic coordinates. Parameters ----------...
[ "def", "geodetic2aer", "(", "lat", ":", "float", ",", "lon", ":", "float", ",", "h", ":", "float", ",", "lat0", ":", "float", ",", "lon0", ":", "float", ",", "h0", ":", "float", ",", "ell", "=", "None", ",", "deg", ":", "bool", "=", "True", ")"...
gives azimuth, elevation and slant range from an Observer to a Point with geodetic coordinates. Parameters ---------- lat : float or numpy.ndarray of float target geodetic latitude lon : float or numpy.ndarray of float target geodetic longitude h : float or numpy.ndarray of float ...
[ "gives", "azimuth", "elevation", "and", "slant", "range", "from", "an", "Observer", "to", "a", "Point", "with", "geodetic", "coordinates", "." ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/aer.py#L52-L90
train
scivision/pymap3d
pymap3d/aer.py
aer2geodetic
def aer2geodetic(az: float, el: float, srange: float, lat0: float, lon0: float, h0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ gives geodetic coordinates of a point with az, el, range from an observer at lat0, lon0, h0 Parame...
python
def aer2geodetic(az: float, el: float, srange: float, lat0: float, lon0: float, h0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ gives geodetic coordinates of a point with az, el, range from an observer at lat0, lon0, h0 Parame...
[ "def", "aer2geodetic", "(", "az", ":", "float", ",", "el", ":", "float", ",", "srange", ":", "float", ",", "lat0", ":", "float", ",", "lon0", ":", "float", ",", "h0", ":", "float", ",", "ell", "=", "None", ",", "deg", ":", "bool", "=", "True", ...
gives geodetic coordinates of a point with az, el, range from an observer at lat0, lon0, h0 Parameters ---------- az : float or numpy.ndarray of float azimuth to target el : float or numpy.ndarray of float elevation to target srange : float or numpy.ndarray of float s...
[ "gives", "geodetic", "coordinates", "of", "a", "point", "with", "az", "el", "range", "from", "an", "observer", "at", "lat0", "lon0", "h0" ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/aer.py#L93-L134
train
scivision/pymap3d
pymap3d/aer.py
eci2aer
def eci2aer(eci: Tuple[float, float, float], lat0: float, lon0: float, h0: float, t: datetime, useastropy: bool = True) -> Tuple[float, float, float]: """ takes ECI coordinates of point and gives az, el, slant range from Observer Parameters ---------- eci : tupl...
python
def eci2aer(eci: Tuple[float, float, float], lat0: float, lon0: float, h0: float, t: datetime, useastropy: bool = True) -> Tuple[float, float, float]: """ takes ECI coordinates of point and gives az, el, slant range from Observer Parameters ---------- eci : tupl...
[ "def", "eci2aer", "(", "eci", ":", "Tuple", "[", "float", ",", "float", ",", "float", "]", ",", "lat0", ":", "float", ",", "lon0", ":", "float", ",", "h0", ":", "float", ",", "t", ":", "datetime", ",", "useastropy", ":", "bool", "=", "True", ")",...
takes ECI coordinates of point and gives az, el, slant range from Observer Parameters ---------- eci : tuple [meters] Nx3 target ECI location (x,y,z) lat0 : float Observer geodetic latitude lon0 : float Observer geodetic longitude h0 : float observer al...
[ "takes", "ECI", "coordinates", "of", "point", "and", "gives", "az", "el", "slant", "range", "from", "Observer" ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/aer.py#L137-L170
train
scivision/pymap3d
pymap3d/aer.py
aer2eci
def aer2eci(az: float, el: float, srange: float, lat0: float, lon0: float, h0: float, t: datetime, ell=None, deg: bool = True, useastropy: bool = True) -> np.ndarray: """ gives ECI of a point from an observer at az, el, slant range Parameters ---------- az : floa...
python
def aer2eci(az: float, el: float, srange: float, lat0: float, lon0: float, h0: float, t: datetime, ell=None, deg: bool = True, useastropy: bool = True) -> np.ndarray: """ gives ECI of a point from an observer at az, el, slant range Parameters ---------- az : floa...
[ "def", "aer2eci", "(", "az", ":", "float", ",", "el", ":", "float", ",", "srange", ":", "float", ",", "lat0", ":", "float", ",", "lon0", ":", "float", ",", "h0", ":", "float", ",", "t", ":", "datetime", ",", "ell", "=", "None", ",", "deg", ":",...
gives ECI of a point from an observer at az, el, slant range Parameters ---------- az : float or numpy.ndarray of float azimuth to target el : float or numpy.ndarray of float elevation to target srange : float or numpy.ndarray of float slant range [meters] lat0 : floa...
[ "gives", "ECI", "of", "a", "point", "from", "an", "observer", "at", "az", "el", "slant", "range" ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/aer.py#L173-L215
train
scivision/pymap3d
pymap3d/aer.py
aer2ecef
def aer2ecef(az: float, el: float, srange: float, lat0: float, lon0: float, alt0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ converts target azimuth, elevation, range from observer at lat0,lon0,alt0 to ECEF coordinates. Parameters ---------- az :...
python
def aer2ecef(az: float, el: float, srange: float, lat0: float, lon0: float, alt0: float, ell=None, deg: bool = True) -> Tuple[float, float, float]: """ converts target azimuth, elevation, range from observer at lat0,lon0,alt0 to ECEF coordinates. Parameters ---------- az :...
[ "def", "aer2ecef", "(", "az", ":", "float", ",", "el", ":", "float", ",", "srange", ":", "float", ",", "lat0", ":", "float", ",", "lon0", ":", "float", ",", "alt0", ":", "float", ",", "ell", "=", "None", ",", "deg", ":", "bool", "=", "True", ")...
converts target azimuth, elevation, range from observer at lat0,lon0,alt0 to ECEF coordinates. Parameters ---------- az : float or numpy.ndarray of float azimuth to target el : float or numpy.ndarray of float elevation to target srange : float or numpy.ndarray of float sl...
[ "converts", "target", "azimuth", "elevation", "range", "from", "observer", "at", "lat0", "lon0", "alt0", "to", "ECEF", "coordinates", "." ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/aer.py#L218-L267
train
scivision/pymap3d
pymap3d/lox.py
isometric
def isometric(lat: float, ell: Ellipsoid = None, deg: bool = True): """ computes isometric latitude of a point on an ellipsoid Parameters ---------- lat : float or numpy.ndarray of float geodetic latitude ell : Ellipsoid, optional reference ellipsoid (default WGS84) ...
python
def isometric(lat: float, ell: Ellipsoid = None, deg: bool = True): """ computes isometric latitude of a point on an ellipsoid Parameters ---------- lat : float or numpy.ndarray of float geodetic latitude ell : Ellipsoid, optional reference ellipsoid (default WGS84) ...
[ "def", "isometric", "(", "lat", ":", "float", ",", "ell", ":", "Ellipsoid", "=", "None", ",", "deg", ":", "bool", "=", "True", ")", ":", "if", "ell", "is", "None", ":", "ell", "=", "Ellipsoid", "(", ")", "f", "=", "ell", ".", "f", "if", "deg", ...
computes isometric latitude of a point on an ellipsoid Parameters ---------- lat : float or numpy.ndarray of float geodetic latitude ell : Ellipsoid, optional reference ellipsoid (default WGS84) deg : bool, optional degrees input/output (False: radians in/out) ...
[ "computes", "isometric", "latitude", "of", "a", "point", "on", "an", "ellipsoid" ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/lox.py#L6-L58
train
scivision/pymap3d
pymap3d/lox.py
loxodrome_inverse
def loxodrome_inverse(lat1: float, lon1: float, lat2: float, lon2: float, ell: Ellipsoid = None, deg: bool = True): """ computes the arc length and azimuth of the loxodrome between two points on the surface of the reference ellipsoid Parameters ---------- lat1 : float or ...
python
def loxodrome_inverse(lat1: float, lon1: float, lat2: float, lon2: float, ell: Ellipsoid = None, deg: bool = True): """ computes the arc length and azimuth of the loxodrome between two points on the surface of the reference ellipsoid Parameters ---------- lat1 : float or ...
[ "def", "loxodrome_inverse", "(", "lat1", ":", "float", ",", "lon1", ":", "float", ",", "lat2", ":", "float", ",", "lon2", ":", "float", ",", "ell", ":", "Ellipsoid", "=", "None", ",", "deg", ":", "bool", "=", "True", ")", ":", "if", "ell", "is", ...
computes the arc length and azimuth of the loxodrome between two points on the surface of the reference ellipsoid Parameters ---------- lat1 : float or numpy.ndarray of float geodetic latitude of first point lon1 : float or numpy.ndarray of float geodetic longitude of first point ...
[ "computes", "the", "arc", "length", "and", "azimuth", "of", "the", "loxodrome", "between", "two", "points", "on", "the", "surface", "of", "the", "reference", "ellipsoid" ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/lox.py#L130-L202
train
scivision/pymap3d
pymap3d/eci.py
eci2ecef
def eci2ecef(eci: np.ndarray, time: datetime, useastropy: bool = True) -> np.ndarray: """ Observer => Point ECI => ECEF Parameters ---------- eci : tuple of float Nx3 target ECI location (x,y,z) [meters] time : datetime.datetime time of obsevation (U...
python
def eci2ecef(eci: np.ndarray, time: datetime, useastropy: bool = True) -> np.ndarray: """ Observer => Point ECI => ECEF Parameters ---------- eci : tuple of float Nx3 target ECI location (x,y,z) [meters] time : datetime.datetime time of obsevation (U...
[ "def", "eci2ecef", "(", "eci", ":", "np", ".", "ndarray", ",", "time", ":", "datetime", ",", "useastropy", ":", "bool", "=", "True", ")", "->", "np", ".", "ndarray", ":", "useastropy", "=", "useastropy", "and", "Time", "if", "useastropy", ":", "gst", ...
Observer => Point ECI => ECEF Parameters ---------- eci : tuple of float Nx3 target ECI location (x,y,z) [meters] time : datetime.datetime time of obsevation (UTC) useastropy : bool, optional use AstroPy for conversion Results ------- x : float target...
[ "Observer", "=", ">", "Point", "ECI", "=", ">", "ECEF" ]
c9cf676594611cdb52ff7e0eca6388c80ed4f63f
https://github.com/scivision/pymap3d/blob/c9cf676594611cdb52ff7e0eca6388c80ed4f63f/pymap3d/eci.py#L12-L58
train
Netflix-Skunkworks/historical
historical/vpc/collector.py
describe_vpc
def describe_vpc(record): """Attempts to describe vpc ids.""" account_id = record['account'] vpc_name = cloudwatch.filter_request_parameters('vpcName', record) vpc_id = cloudwatch.filter_request_parameters('vpcId', record) try: if vpc_id and vpc_name: # pylint: disable=R1705 re...
python
def describe_vpc(record): """Attempts to describe vpc ids.""" account_id = record['account'] vpc_name = cloudwatch.filter_request_parameters('vpcName', record) vpc_id = cloudwatch.filter_request_parameters('vpcId', record) try: if vpc_id and vpc_name: # pylint: disable=R1705 re...
[ "def", "describe_vpc", "(", "record", ")", ":", "account_id", "=", "record", "[", "'account'", "]", "vpc_name", "=", "cloudwatch", ".", "filter_request_parameters", "(", "'vpcName'", ",", "record", ")", "vpc_id", "=", "cloudwatch", ".", "filter_request_parameters"...
Attempts to describe vpc ids.
[ "Attempts", "to", "describe", "vpc", "ids", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/vpc/collector.py#L44-L75
train
Netflix-Skunkworks/historical
historical/vpc/collector.py
create_delete_model
def create_delete_model(record): """Create a vpc model from a record.""" data = cloudwatch.get_historical_base_info(record) vpc_id = cloudwatch.filter_request_parameters('vpcId', record) arn = get_arn(vpc_id, cloudwatch.get_region(record), record['account']) LOG.debug(F'[-] Deleting Dynamodb Reco...
python
def create_delete_model(record): """Create a vpc model from a record.""" data = cloudwatch.get_historical_base_info(record) vpc_id = cloudwatch.filter_request_parameters('vpcId', record) arn = get_arn(vpc_id, cloudwatch.get_region(record), record['account']) LOG.debug(F'[-] Deleting Dynamodb Reco...
[ "def", "create_delete_model", "(", "record", ")", ":", "data", "=", "cloudwatch", ".", "get_historical_base_info", "(", "record", ")", "vpc_id", "=", "cloudwatch", ".", "filter_request_parameters", "(", "'vpcId'", ",", "record", ")", "arn", "=", "get_arn", "(", ...
Create a vpc model from a record.
[ "Create", "a", "vpc", "model", "from", "a", "record", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/vpc/collector.py#L78-L102
train
Netflix-Skunkworks/historical
historical/vpc/collector.py
handler
def handler(event, context): # pylint: disable=W0613 """ Historical vpc event collector. This collector is responsible for processing Cloudwatch events and polling events. """ records = deserialize_records(event['Records']) # Split records into two groups, update and delete. # We don't wan...
python
def handler(event, context): # pylint: disable=W0613 """ Historical vpc event collector. This collector is responsible for processing Cloudwatch events and polling events. """ records = deserialize_records(event['Records']) # Split records into two groups, update and delete. # We don't wan...
[ "def", "handler", "(", "event", ",", "context", ")", ":", "records", "=", "deserialize_records", "(", "event", "[", "'Records'", "]", ")", "update_records", ",", "delete_records", "=", "group_records_by_type", "(", "records", ",", "UPDATE_EVENTS", ")", "capture_...
Historical vpc event collector. This collector is responsible for processing Cloudwatch events and polling events.
[ "Historical", "vpc", "event", "collector", ".", "This", "collector", "is", "responsible", "for", "processing", "Cloudwatch", "events", "and", "polling", "events", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/vpc/collector.py#L165-L183
train
Netflix-Skunkworks/historical
historical/common/dynamodb.py
default_diff
def default_diff(latest_config, current_config): """Determine if two revisions have actually changed.""" # Pop off the fields we don't care about: pop_no_diff_fields(latest_config, current_config) diff = DeepDiff( latest_config, current_config, ignore_order=True ) return...
python
def default_diff(latest_config, current_config): """Determine if two revisions have actually changed.""" # Pop off the fields we don't care about: pop_no_diff_fields(latest_config, current_config) diff = DeepDiff( latest_config, current_config, ignore_order=True ) return...
[ "def", "default_diff", "(", "latest_config", ",", "current_config", ")", ":", "pop_no_diff_fields", "(", "latest_config", ",", "current_config", ")", "diff", "=", "DeepDiff", "(", "latest_config", ",", "current_config", ",", "ignore_order", "=", "True", ")", "retu...
Determine if two revisions have actually changed.
[ "Determine", "if", "two", "revisions", "have", "actually", "changed", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/dynamodb.py#L33-L43
train
Netflix-Skunkworks/historical
historical/common/dynamodb.py
pop_no_diff_fields
def pop_no_diff_fields(latest_config, current_config): """Pops off fields that should not be included in the diff.""" for field in ['userIdentity', 'principalId', 'userAgent', 'sourceIpAddress', 'requestParameters', 'eventName']: latest_config.pop(field, None) current_config.pop(field, None)
python
def pop_no_diff_fields(latest_config, current_config): """Pops off fields that should not be included in the diff.""" for field in ['userIdentity', 'principalId', 'userAgent', 'sourceIpAddress', 'requestParameters', 'eventName']: latest_config.pop(field, None) current_config.pop(field, None)
[ "def", "pop_no_diff_fields", "(", "latest_config", ",", "current_config", ")", ":", "for", "field", "in", "[", "'userIdentity'", ",", "'principalId'", ",", "'userAgent'", ",", "'sourceIpAddress'", ",", "'requestParameters'", ",", "'eventName'", "]", ":", "latest_con...
Pops off fields that should not be included in the diff.
[ "Pops", "off", "fields", "that", "should", "not", "be", "included", "in", "the", "diff", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/dynamodb.py#L46-L50
train
Netflix-Skunkworks/historical
historical/common/dynamodb.py
modify_record
def modify_record(durable_model, current_revision, arn, event_time, diff_func): """Handles a DynamoDB MODIFY event type.""" # We want the newest items first. # See: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html items = list(durable_model.query( arn, (durable_...
python
def modify_record(durable_model, current_revision, arn, event_time, diff_func): """Handles a DynamoDB MODIFY event type.""" # We want the newest items first. # See: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html items = list(durable_model.query( arn, (durable_...
[ "def", "modify_record", "(", "durable_model", ",", "current_revision", ",", "arn", ",", "event_time", ",", "diff_func", ")", ":", "items", "=", "list", "(", "durable_model", ".", "query", "(", "arn", ",", "(", "durable_model", ".", "eventTime", "<=", "event_...
Handles a DynamoDB MODIFY event type.
[ "Handles", "a", "DynamoDB", "MODIFY", "event", "type", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/dynamodb.py#L82-L108
train
Netflix-Skunkworks/historical
historical/common/dynamodb.py
deserialize_current_record_to_durable_model
def deserialize_current_record_to_durable_model(record, current_model, durable_model): """ Utility function that will take a dynamo event record and turn it into the proper pynamo object. This will properly deserialize the ugly Dynamo datatypes away. :param record: :param current_model: :param ...
python
def deserialize_current_record_to_durable_model(record, current_model, durable_model): """ Utility function that will take a dynamo event record and turn it into the proper pynamo object. This will properly deserialize the ugly Dynamo datatypes away. :param record: :param current_model: :param ...
[ "def", "deserialize_current_record_to_durable_model", "(", "record", ",", "current_model", ",", "durable_model", ")", ":", "if", "record", ".", "get", "(", "EVENT_TOO_BIG_FLAG", ")", ":", "record", "=", "get_full_current_object", "(", "record", "[", "'dynamodb'", "]...
Utility function that will take a dynamo event record and turn it into the proper pynamo object. This will properly deserialize the ugly Dynamo datatypes away. :param record: :param current_model: :param durable_model: :return:
[ "Utility", "function", "that", "will", "take", "a", "dynamo", "event", "record", "and", "turn", "it", "into", "the", "proper", "pynamo", "object", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/dynamodb.py#L168-L203
train
Netflix-Skunkworks/historical
historical/common/dynamodb.py
deserialize_current_record_to_current_model
def deserialize_current_record_to_current_model(record, current_model): """ Utility function that will take a Dynamo event record and turn it into the proper Current Dynamo object. This will remove the "current table" specific fields, and properly deserialize the ugly Dynamo datatypes away. :param reco...
python
def deserialize_current_record_to_current_model(record, current_model): """ Utility function that will take a Dynamo event record and turn it into the proper Current Dynamo object. This will remove the "current table" specific fields, and properly deserialize the ugly Dynamo datatypes away. :param reco...
[ "def", "deserialize_current_record_to_current_model", "(", "record", ",", "current_model", ")", ":", "if", "record", ".", "get", "(", "EVENT_TOO_BIG_FLAG", ")", ":", "return", "get_full_current_object", "(", "record", "[", "'dynamodb'", "]", "[", "'Keys'", "]", "[...
Utility function that will take a Dynamo event record and turn it into the proper Current Dynamo object. This will remove the "current table" specific fields, and properly deserialize the ugly Dynamo datatypes away. :param record: :param current_model: :return:
[ "Utility", "function", "that", "will", "take", "a", "Dynamo", "event", "record", "and", "turn", "it", "into", "the", "proper", "Current", "Dynamo", "object", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/dynamodb.py#L206-L226
train
Netflix-Skunkworks/historical
historical/common/dynamodb.py
deserialize_durable_record_to_durable_model
def deserialize_durable_record_to_durable_model(record, durable_model): """ Utility function that will take a Dynamo event record and turn it into the proper Durable Dynamo object. This will properly deserialize the ugly Dynamo datatypes away. :param record: :param durable_model: :return: "...
python
def deserialize_durable_record_to_durable_model(record, durable_model): """ Utility function that will take a Dynamo event record and turn it into the proper Durable Dynamo object. This will properly deserialize the ugly Dynamo datatypes away. :param record: :param durable_model: :return: "...
[ "def", "deserialize_durable_record_to_durable_model", "(", "record", ",", "durable_model", ")", ":", "if", "record", ".", "get", "(", "EVENT_TOO_BIG_FLAG", ")", ":", "return", "get_full_durable_object", "(", "record", "[", "'dynamodb'", "]", "[", "'Keys'", "]", "[...
Utility function that will take a Dynamo event record and turn it into the proper Durable Dynamo object. This will properly deserialize the ugly Dynamo datatypes away. :param record: :param durable_model: :return:
[ "Utility", "function", "that", "will", "take", "a", "Dynamo", "event", "record", "and", "turn", "it", "into", "the", "proper", "Durable", "Dynamo", "object", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/dynamodb.py#L229-L251
train
Netflix-Skunkworks/historical
historical/common/dynamodb.py
deserialize_durable_record_to_current_model
def deserialize_durable_record_to_current_model(record, current_model): """ Utility function that will take a Durable Dynamo event record and turn it into the proper Current Dynamo object. This will properly deserialize the ugly Dynamo datatypes away. :param record: :param current_model: :retur...
python
def deserialize_durable_record_to_current_model(record, current_model): """ Utility function that will take a Durable Dynamo event record and turn it into the proper Current Dynamo object. This will properly deserialize the ugly Dynamo datatypes away. :param record: :param current_model: :retur...
[ "def", "deserialize_durable_record_to_current_model", "(", "record", ",", "current_model", ")", ":", "if", "record", ".", "get", "(", "EVENT_TOO_BIG_FLAG", ")", ":", "return", "get_full_current_object", "(", "record", "[", "'dynamodb'", "]", "[", "'Keys'", "]", "[...
Utility function that will take a Durable Dynamo event record and turn it into the proper Current Dynamo object. This will properly deserialize the ugly Dynamo datatypes away. :param record: :param current_model: :return:
[ "Utility", "function", "that", "will", "take", "a", "Durable", "Dynamo", "event", "record", "and", "turn", "it", "into", "the", "proper", "Current", "Dynamo", "object", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/dynamodb.py#L254-L275
train
Netflix-Skunkworks/historical
historical/models.py
HistoricalPollerTaskEventModel.serialize_me
def serialize_me(self, account_id, region, next_token=None): """Dumps the proper JSON for the schema. :param account_id: :param region: :param next_token: :return: """ payload = { 'account_id': account_id, 'region': region } ...
python
def serialize_me(self, account_id, region, next_token=None): """Dumps the proper JSON for the schema. :param account_id: :param region: :param next_token: :return: """ payload = { 'account_id': account_id, 'region': region } ...
[ "def", "serialize_me", "(", "self", ",", "account_id", ",", "region", ",", "next_token", "=", "None", ")", ":", "payload", "=", "{", "'account_id'", ":", "account_id", ",", "'region'", ":", "region", "}", "if", "next_token", ":", "payload", "[", "'next_tok...
Dumps the proper JSON for the schema. :param account_id: :param region: :param next_token: :return:
[ "Dumps", "the", "proper", "JSON", "for", "the", "schema", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/models.py#L136-L152
train
Netflix-Skunkworks/historical
historical/models.py
SimpleDurableSchema.serialize_me
def serialize_me(self, arn, event_time, tech, item=None): """Dumps the proper JSON for the schema. If the event is too big, then don't include the item. :param arn: :param event_time: :param tech: :param item: :return: """ payload = { 'arn': a...
python
def serialize_me(self, arn, event_time, tech, item=None): """Dumps the proper JSON for the schema. If the event is too big, then don't include the item. :param arn: :param event_time: :param tech: :param item: :return: """ payload = { 'arn': a...
[ "def", "serialize_me", "(", "self", ",", "arn", ",", "event_time", ",", "tech", ",", "item", "=", "None", ")", ":", "payload", "=", "{", "'arn'", ":", "arn", ",", "'event_time'", ":", "event_time", ",", "'tech'", ":", "tech", "}", "if", "item", ":", ...
Dumps the proper JSON for the schema. If the event is too big, then don't include the item. :param arn: :param event_time: :param tech: :param item: :return:
[ "Dumps", "the", "proper", "JSON", "for", "the", "schema", ".", "If", "the", "event", "is", "too", "big", "then", "don", "t", "include", "the", "item", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/models.py#L169-L190
train
Netflix-Skunkworks/historical
historical/attributes.py
fix_decimals
def fix_decimals(obj): """Removes the stupid Decimals See: https://github.com/boto/boto3/issues/369#issuecomment-302137290 """ if isinstance(obj, list): for i in range(len(obj)): obj[i] = fix_decimals(obj[i]) return obj elif isinstance(obj, dict): for key, value...
python
def fix_decimals(obj): """Removes the stupid Decimals See: https://github.com/boto/boto3/issues/369#issuecomment-302137290 """ if isinstance(obj, list): for i in range(len(obj)): obj[i] = fix_decimals(obj[i]) return obj elif isinstance(obj, dict): for key, value...
[ "def", "fix_decimals", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "list", ")", ":", "for", "i", "in", "range", "(", "len", "(", "obj", ")", ")", ":", "obj", "[", "i", "]", "=", "fix_decimals", "(", "obj", "[", "i", "]", ")", "...
Removes the stupid Decimals See: https://github.com/boto/boto3/issues/369#issuecomment-302137290
[ "Removes", "the", "stupid", "Decimals" ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/attributes.py#L62-L84
train
Netflix-Skunkworks/historical
historical/attributes.py
EventTimeAttribute.serialize
def serialize(self, value): """Takes a datetime object and returns a string""" if isinstance(value, str): return value return value.strftime(DATETIME_FORMAT)
python
def serialize(self, value): """Takes a datetime object and returns a string""" if isinstance(value, str): return value return value.strftime(DATETIME_FORMAT)
[ "def", "serialize", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "return", "value", "return", "value", ".", "strftime", "(", "DATETIME_FORMAT", ")" ]
Takes a datetime object and returns a string
[ "Takes", "a", "datetime", "object", "and", "returns", "a", "string" ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/attributes.py#L45-L49
train
Netflix-Skunkworks/historical
historical/common/util.py
pull_tag_dict
def pull_tag_dict(data): """This will pull out a list of Tag Name-Value objects, and return it as a dictionary. :param data: The dict collected from the collector. :returns dict: A dict of the tag names and their corresponding values. """ # If there are tags, set them to a normal dict, vs. a list o...
python
def pull_tag_dict(data): """This will pull out a list of Tag Name-Value objects, and return it as a dictionary. :param data: The dict collected from the collector. :returns dict: A dict of the tag names and their corresponding values. """ # If there are tags, set them to a normal dict, vs. a list o...
[ "def", "pull_tag_dict", "(", "data", ")", ":", "tags", "=", "data", ".", "pop", "(", "'Tags'", ",", "{", "}", ")", "or", "{", "}", "if", "tags", ":", "proper_tags", "=", "{", "}", "for", "tag", "in", "tags", ":", "proper_tags", "[", "tag", "[", ...
This will pull out a list of Tag Name-Value objects, and return it as a dictionary. :param data: The dict collected from the collector. :returns dict: A dict of the tag names and their corresponding values.
[ "This", "will", "pull", "out", "a", "list", "of", "Tag", "Name", "-", "Value", "objects", "and", "return", "it", "as", "a", "dictionary", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/util.py#L39-L54
train
Netflix-Skunkworks/historical
historical/s3/collector.py
create_delete_model
def create_delete_model(record): """Create an S3 model from a record.""" arn = f"arn:aws:s3:::{cloudwatch.filter_request_parameters('bucketName', record)}" LOG.debug(f'[-] Deleting Dynamodb Records. Hash Key: {arn}') data = { 'arn': arn, 'principalId': cloudwatch.get_principal(record), ...
python
def create_delete_model(record): """Create an S3 model from a record.""" arn = f"arn:aws:s3:::{cloudwatch.filter_request_parameters('bucketName', record)}" LOG.debug(f'[-] Deleting Dynamodb Records. Hash Key: {arn}') data = { 'arn': arn, 'principalId': cloudwatch.get_principal(record), ...
[ "def", "create_delete_model", "(", "record", ")", ":", "arn", "=", "f\"arn:aws:s3:::{cloudwatch.filter_request_parameters('bucketName', record)}\"", "LOG", ".", "debug", "(", "f'[-] Deleting Dynamodb Records. Hash Key: {arn}'", ")", "data", "=", "{", "'arn'", ":", "arn", ",...
Create an S3 model from a record.
[ "Create", "an", "S3", "model", "from", "a", "record", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/s3/collector.py#L55-L74
train
Netflix-Skunkworks/historical
historical/s3/collector.py
process_delete_records
def process_delete_records(delete_records): """Process the requests for S3 bucket deletions""" for rec in delete_records: arn = f"arn:aws:s3:::{rec['detail']['requestParameters']['bucketName']}" # Need to check if the event is NEWER than the previous event in case # events are out of or...
python
def process_delete_records(delete_records): """Process the requests for S3 bucket deletions""" for rec in delete_records: arn = f"arn:aws:s3:::{rec['detail']['requestParameters']['bucketName']}" # Need to check if the event is NEWER than the previous event in case # events are out of or...
[ "def", "process_delete_records", "(", "delete_records", ")", ":", "for", "rec", "in", "delete_records", ":", "arn", "=", "f\"arn:aws:s3:::{rec['detail']['requestParameters']['bucketName']}\"", "try", ":", "LOG", ".", "debug", "(", "f'[-] Deleting bucket: {arn}'", ")", "mo...
Process the requests for S3 bucket deletions
[ "Process", "the", "requests", "for", "S3", "bucket", "deletions" ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/s3/collector.py#L77-L96
train
Netflix-Skunkworks/historical
historical/s3/collector.py
process_update_records
def process_update_records(update_records): """Process the requests for S3 bucket update requests""" events = sorted(update_records, key=lambda x: x['account']) # Group records by account for more efficient processing for account_id, events in groupby(events, lambda x: x['account']): events = l...
python
def process_update_records(update_records): """Process the requests for S3 bucket update requests""" events = sorted(update_records, key=lambda x: x['account']) # Group records by account for more efficient processing for account_id, events in groupby(events, lambda x: x['account']): events = l...
[ "def", "process_update_records", "(", "update_records", ")", ":", "events", "=", "sorted", "(", "update_records", ",", "key", "=", "lambda", "x", ":", "x", "[", "'account'", "]", ")", "for", "account_id", ",", "events", "in", "groupby", "(", "events", ",",...
Process the requests for S3 bucket update requests
[ "Process", "the", "requests", "for", "S3", "bucket", "update", "requests" ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/s3/collector.py#L99-L179
train
Netflix-Skunkworks/historical
historical/s3/collector.py
handler
def handler(event, context): # pylint: disable=W0613 """ Historical S3 event collector. This collector is responsible for processing CloudWatch events and polling events. """ records = deserialize_records(event['Records']) # Split records into two groups, update and delete. # We don't wan...
python
def handler(event, context): # pylint: disable=W0613 """ Historical S3 event collector. This collector is responsible for processing CloudWatch events and polling events. """ records = deserialize_records(event['Records']) # Split records into two groups, update and delete. # We don't wan...
[ "def", "handler", "(", "event", ",", "context", ")", ":", "records", "=", "deserialize_records", "(", "event", "[", "'Records'", "]", ")", "update_records", ",", "delete_records", "=", "group_records_by_type", "(", "records", ",", "UPDATE_EVENTS", ")", "LOG", ...
Historical S3 event collector. This collector is responsible for processing CloudWatch events and polling events.
[ "Historical", "S3", "event", "collector", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/s3/collector.py#L183-L203
train
Netflix-Skunkworks/historical
historical/common/accounts.py
get_historical_accounts
def get_historical_accounts(): """Fetches valid accounts from SWAG if enabled or a list accounts.""" if os.environ.get('SWAG_BUCKET', False): swag_opts = { 'swag.type': 's3', 'swag.bucket_name': os.environ['SWAG_BUCKET'], 'swag.data_file': os.environ.get('SWAG_DATA_FI...
python
def get_historical_accounts(): """Fetches valid accounts from SWAG if enabled or a list accounts.""" if os.environ.get('SWAG_BUCKET', False): swag_opts = { 'swag.type': 's3', 'swag.bucket_name': os.environ['SWAG_BUCKET'], 'swag.data_file': os.environ.get('SWAG_DATA_FI...
[ "def", "get_historical_accounts", "(", ")", ":", "if", "os", ".", "environ", ".", "get", "(", "'SWAG_BUCKET'", ",", "False", ")", ":", "swag_opts", "=", "{", "'swag.type'", ":", "'s3'", ",", "'swag.bucket_name'", ":", "os", ".", "environ", "[", "'SWAG_BUCK...
Fetches valid accounts from SWAG if enabled or a list accounts.
[ "Fetches", "valid", "accounts", "from", "SWAG", "if", "enabled", "or", "a", "list", "accounts", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/accounts.py#L26-L47
train
Netflix-Skunkworks/historical
historical/s3/poller.py
poller_processor_handler
def poller_processor_handler(event, context): # pylint: disable=W0613 """ Historical S3 Poller Processor. This will receive events from the Poller Tasker, and will list all objects of a given technology for an account/region pair. This will generate `polling events` which simulate changes. These polli...
python
def poller_processor_handler(event, context): # pylint: disable=W0613 """ Historical S3 Poller Processor. This will receive events from the Poller Tasker, and will list all objects of a given technology for an account/region pair. This will generate `polling events` which simulate changes. These polli...
[ "def", "poller_processor_handler", "(", "event", ",", "context", ")", ":", "LOG", ".", "debug", "(", "'[@] Running Poller...'", ")", "queue_url", "=", "get_queue_url", "(", "os", ".", "environ", ".", "get", "(", "'POLLER_QUEUE_NAME'", ",", "'HistoricalS3Poller'", ...
Historical S3 Poller Processor. This will receive events from the Poller Tasker, and will list all objects of a given technology for an account/region pair. This will generate `polling events` which simulate changes. These polling events contain configuration data such as the account/region defining where ...
[ "Historical", "S3", "Poller", "Processor", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/s3/poller.py#L58-L87
train
Netflix-Skunkworks/historical
historical/common/proxy.py
detect_global_table_updates
def detect_global_table_updates(record): """This will detect DDB Global Table updates that are not relevant to application data updates. These need to be skipped over as they are pure noise. :param record: :return: """ # This only affects MODIFY events. if record['eventName'] == 'MODIFY'...
python
def detect_global_table_updates(record): """This will detect DDB Global Table updates that are not relevant to application data updates. These need to be skipped over as they are pure noise. :param record: :return: """ # This only affects MODIFY events. if record['eventName'] == 'MODIFY'...
[ "def", "detect_global_table_updates", "(", "record", ")", ":", "if", "record", "[", "'eventName'", "]", "==", "'MODIFY'", ":", "old_image", "=", "remove_global_dynamo_specific_fields", "(", "record", "[", "'dynamodb'", "]", "[", "'OldImage'", "]", ")", "new_image"...
This will detect DDB Global Table updates that are not relevant to application data updates. These need to be skipped over as they are pure noise. :param record: :return:
[ "This", "will", "detect", "DDB", "Global", "Table", "updates", "that", "are", "not", "relevant", "to", "application", "data", "updates", ".", "These", "need", "to", "be", "skipped", "over", "as", "they", "are", "pure", "noise", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/proxy.py#L126-L142
train
Netflix-Skunkworks/historical
historical/s3/differ.py
handler
def handler(event, context): # pylint: disable=W0613 """ Historical S3 event differ. Listens to the Historical current table and determines if there are differences that need to be persisted in the historical record. """ # De-serialize the records: records = deserialize_records(event['Reco...
python
def handler(event, context): # pylint: disable=W0613 """ Historical S3 event differ. Listens to the Historical current table and determines if there are differences that need to be persisted in the historical record. """ # De-serialize the records: records = deserialize_records(event['Reco...
[ "def", "handler", "(", "event", ",", "context", ")", ":", "records", "=", "deserialize_records", "(", "event", "[", "'Records'", "]", ")", "for", "record", "in", "records", ":", "process_dynamodb_differ_record", "(", "record", ",", "CurrentS3Model", ",", "Dura...
Historical S3 event differ. Listens to the Historical current table and determines if there are differences that need to be persisted in the historical record.
[ "Historical", "S3", "event", "differ", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/s3/differ.py#L26-L37
train
Netflix-Skunkworks/historical
historical/cli.py
new
def new(): """Creates a new historical technology.""" dir_path = os.path.dirname(os.path.realpath(__file__)) cookiecutter(os.path.join(dir_path, 'historical-cookiecutter/'))
python
def new(): """Creates a new historical technology.""" dir_path = os.path.dirname(os.path.realpath(__file__)) cookiecutter(os.path.join(dir_path, 'historical-cookiecutter/'))
[ "def", "new", "(", ")", ":", "dir_path", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "__file__", ")", ")", "cookiecutter", "(", "os", ".", "path", ".", "join", "(", "dir_path", ",", "'historical-cookiecutter/'"...
Creates a new historical technology.
[ "Creates", "a", "new", "historical", "technology", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/cli.py#L30-L33
train
Netflix-Skunkworks/historical
historical/vpc/poller.py
poller_tasker_handler
def poller_tasker_handler(event, context): # pylint: disable=W0613 """ Historical VPC Poller Tasker. The Poller is run at a set interval in order to ensure that changes do not go undetected by Historical. Historical pollers generate `polling events` which simulate changes. These polling events contai...
python
def poller_tasker_handler(event, context): # pylint: disable=W0613 """ Historical VPC Poller Tasker. The Poller is run at a set interval in order to ensure that changes do not go undetected by Historical. Historical pollers generate `polling events` which simulate changes. These polling events contai...
[ "def", "poller_tasker_handler", "(", "event", ",", "context", ")", ":", "LOG", ".", "debug", "(", "'[@] Running Poller Tasker...'", ")", "queue_url", "=", "get_queue_url", "(", "os", ".", "environ", ".", "get", "(", "'POLLER_TASKER_QUEUE_NAME'", ",", "'HistoricalV...
Historical VPC Poller Tasker. The Poller is run at a set interval in order to ensure that changes do not go undetected by Historical. Historical pollers generate `polling events` which simulate changes. These polling events contain configuration data such as the account/region defining where the collector...
[ "Historical", "VPC", "Poller", "Tasker", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/vpc/poller.py#L30-L57
train
Netflix-Skunkworks/historical
historical/common/sqs.py
chunks
def chunks(event_list, chunk_size): """Yield successive n-sized chunks from the event list.""" for i in range(0, len(event_list), chunk_size): yield event_list[i:i + chunk_size]
python
def chunks(event_list, chunk_size): """Yield successive n-sized chunks from the event list.""" for i in range(0, len(event_list), chunk_size): yield event_list[i:i + chunk_size]
[ "def", "chunks", "(", "event_list", ",", "chunk_size", ")", ":", "for", "i", "in", "range", "(", "0", ",", "len", "(", "event_list", ")", ",", "chunk_size", ")", ":", "yield", "event_list", "[", "i", ":", "i", "+", "chunk_size", "]" ]
Yield successive n-sized chunks from the event list.
[ "Yield", "successive", "n", "-", "sized", "chunks", "from", "the", "event", "list", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/sqs.py#L21-L24
train
Netflix-Skunkworks/historical
historical/common/sqs.py
get_queue_url
def get_queue_url(queue_name): """Get the URL of the SQS queue to send events to.""" client = boto3.client("sqs", CURRENT_REGION) queue = client.get_queue_url(QueueName=queue_name) return queue["QueueUrl"]
python
def get_queue_url(queue_name): """Get the URL of the SQS queue to send events to.""" client = boto3.client("sqs", CURRENT_REGION) queue = client.get_queue_url(QueueName=queue_name) return queue["QueueUrl"]
[ "def", "get_queue_url", "(", "queue_name", ")", ":", "client", "=", "boto3", ".", "client", "(", "\"sqs\"", ",", "CURRENT_REGION", ")", "queue", "=", "client", ".", "get_queue_url", "(", "QueueName", "=", "queue_name", ")", "return", "queue", "[", "\"QueueUr...
Get the URL of the SQS queue to send events to.
[ "Get", "the", "URL", "of", "the", "SQS", "queue", "to", "send", "events", "to", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/sqs.py#L27-L32
train
Netflix-Skunkworks/historical
historical/common/sqs.py
produce_events
def produce_events(events, queue_url, batch_size=10, randomize_delay=0): """ Efficiently sends events to the SQS event queue. Note: SQS has a max size of 10 items. Please be aware that this can make the messages go past size -- even with shrinking messages! Events can get randomized delays, maxim...
python
def produce_events(events, queue_url, batch_size=10, randomize_delay=0): """ Efficiently sends events to the SQS event queue. Note: SQS has a max size of 10 items. Please be aware that this can make the messages go past size -- even with shrinking messages! Events can get randomized delays, maxim...
[ "def", "produce_events", "(", "events", ",", "queue_url", ",", "batch_size", "=", "10", ",", "randomize_delay", "=", "0", ")", ":", "client", "=", "boto3", ".", "client", "(", "'sqs'", ",", "region_name", "=", "CURRENT_REGION", ")", "for", "chunk", "in", ...
Efficiently sends events to the SQS event queue. Note: SQS has a max size of 10 items. Please be aware that this can make the messages go past size -- even with shrinking messages! Events can get randomized delays, maximum of 900 seconds. Set that in `randomize_delay` :param events: :param queue_...
[ "Efficiently", "sends", "events", "to", "the", "SQS", "event", "queue", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/sqs.py#L55-L73
train
Netflix-Skunkworks/historical
historical/security_group/collector.py
describe_group
def describe_group(record, region): """Attempts to describe group ids.""" account_id = record['account'] group_name = cloudwatch.filter_request_parameters('groupName', record) vpc_id = cloudwatch.filter_request_parameters('vpcId', record) group_id = cloudwatch.filter_request_parameters('groupId', r...
python
def describe_group(record, region): """Attempts to describe group ids.""" account_id = record['account'] group_name = cloudwatch.filter_request_parameters('groupName', record) vpc_id = cloudwatch.filter_request_parameters('vpcId', record) group_id = cloudwatch.filter_request_parameters('groupId', r...
[ "def", "describe_group", "(", "record", ",", "region", ")", ":", "account_id", "=", "record", "[", "'account'", "]", "group_name", "=", "cloudwatch", ".", "filter_request_parameters", "(", "'groupName'", ",", "record", ")", "vpc_id", "=", "cloudwatch", ".", "f...
Attempts to describe group ids.
[ "Attempts", "to", "describe", "group", "ids", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/security_group/collector.py#L47-L92
train
Netflix-Skunkworks/historical
historical/security_group/collector.py
create_delete_model
def create_delete_model(record): """Create a security group model from a record.""" data = cloudwatch.get_historical_base_info(record) group_id = cloudwatch.filter_request_parameters('groupId', record) # vpc_id = cloudwatch.filter_request_parameters('vpcId', record) # group_name = cloudwatch.filter...
python
def create_delete_model(record): """Create a security group model from a record.""" data = cloudwatch.get_historical_base_info(record) group_id = cloudwatch.filter_request_parameters('groupId', record) # vpc_id = cloudwatch.filter_request_parameters('vpcId', record) # group_name = cloudwatch.filter...
[ "def", "create_delete_model", "(", "record", ")", ":", "data", "=", "cloudwatch", ".", "get_historical_base_info", "(", "record", ")", "group_id", "=", "cloudwatch", ".", "filter_request_parameters", "(", "'groupId'", ",", "record", ")", "arn", "=", "get_arn", "...
Create a security group model from a record.
[ "Create", "a", "security", "group", "model", "from", "a", "record", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/security_group/collector.py#L95-L119
train
Netflix-Skunkworks/historical
historical/constants.py
extract_log_level_from_environment
def extract_log_level_from_environment(k, default): """Gets the log level from the environment variable.""" return LOG_LEVELS.get(os.environ.get(k)) or int(os.environ.get(k, default))
python
def extract_log_level_from_environment(k, default): """Gets the log level from the environment variable.""" return LOG_LEVELS.get(os.environ.get(k)) or int(os.environ.get(k, default))
[ "def", "extract_log_level_from_environment", "(", "k", ",", "default", ")", ":", "return", "LOG_LEVELS", ".", "get", "(", "os", ".", "environ", ".", "get", "(", "k", ")", ")", "or", "int", "(", "os", ".", "environ", ".", "get", "(", "k", ",", "defaul...
Gets the log level from the environment variable.
[ "Gets", "the", "log", "level", "from", "the", "environment", "variable", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/constants.py#L21-L23
train
Netflix-Skunkworks/historical
historical/common/cloudwatch.py
filter_request_parameters
def filter_request_parameters(field_name, msg, look_in_response=False): """ From an event, extract the field name from the message. Different API calls put this information in different places, so check a few places. """ val = msg['detail'].get(field_name, None) try: if not val: ...
python
def filter_request_parameters(field_name, msg, look_in_response=False): """ From an event, extract the field name from the message. Different API calls put this information in different places, so check a few places. """ val = msg['detail'].get(field_name, None) try: if not val: ...
[ "def", "filter_request_parameters", "(", "field_name", ",", "msg", ",", "look_in_response", "=", "False", ")", ":", "val", "=", "msg", "[", "'detail'", "]", ".", "get", "(", "field_name", ",", "None", ")", "try", ":", "if", "not", "val", ":", "val", "=...
From an event, extract the field name from the message. Different API calls put this information in different places, so check a few places.
[ "From", "an", "event", "extract", "the", "field", "name", "from", "the", "message", ".", "Different", "API", "calls", "put", "this", "information", "in", "different", "places", "so", "check", "a", "few", "places", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/cloudwatch.py#L14-L33
train
Netflix-Skunkworks/historical
historical/common/cloudwatch.py
get_historical_base_info
def get_historical_base_info(event): """Gets the base details from the CloudWatch Event.""" data = { 'principalId': get_principal(event), 'userIdentity': get_user_identity(event), 'accountId': event['account'], 'userAgent': event['detail'].get('userAgent'), 'sourceIpAddre...
python
def get_historical_base_info(event): """Gets the base details from the CloudWatch Event.""" data = { 'principalId': get_principal(event), 'userIdentity': get_user_identity(event), 'accountId': event['account'], 'userAgent': event['detail'].get('userAgent'), 'sourceIpAddre...
[ "def", "get_historical_base_info", "(", "event", ")", ":", "data", "=", "{", "'principalId'", ":", "get_principal", "(", "event", ")", ",", "'userIdentity'", ":", "get_user_identity", "(", "event", ")", ",", "'accountId'", ":", "event", "[", "'account'", "]", ...
Gets the base details from the CloudWatch Event.
[ "Gets", "the", "base", "details", "from", "the", "CloudWatch", "Event", "." ]
c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a
https://github.com/Netflix-Skunkworks/historical/blob/c3ebaa8388a3fe67e23a6c9c6b04c3e618497c4a/historical/common/cloudwatch.py#L67-L87
train
desbma/GoogleSpeech
google_speech/__init__.py
Speech.splitText
def splitText(text): """ Split text into sub segments of size not bigger than MAX_SEGMENT_SIZE. """ segments = [] remaining_text = __class__.cleanSpaces(text) while len(remaining_text) > __class__.MAX_SEGMENT_SIZE: cur_text = remaining_text[:__class__.MAX_SEGMENT_SIZE] # try to split at pu...
python
def splitText(text): """ Split text into sub segments of size not bigger than MAX_SEGMENT_SIZE. """ segments = [] remaining_text = __class__.cleanSpaces(text) while len(remaining_text) > __class__.MAX_SEGMENT_SIZE: cur_text = remaining_text[:__class__.MAX_SEGMENT_SIZE] # try to split at pu...
[ "def", "splitText", "(", "text", ")", ":", "segments", "=", "[", "]", "remaining_text", "=", "__class__", ".", "cleanSpaces", "(", "text", ")", "while", "len", "(", "remaining_text", ")", ">", "__class__", ".", "MAX_SEGMENT_SIZE", ":", "cur_text", "=", "re...
Split text into sub segments of size not bigger than MAX_SEGMENT_SIZE.
[ "Split", "text", "into", "sub", "segments", "of", "size", "not", "bigger", "than", "MAX_SEGMENT_SIZE", "." ]
6d3ec62dc26400ccb4f2e77b8ccd4cb416141233
https://github.com/desbma/GoogleSpeech/blob/6d3ec62dc26400ccb4f2e77b8ccd4cb416141233/google_speech/__init__.py#L99-L130
train
desbma/GoogleSpeech
google_speech/__init__.py
Speech.play
def play(self, sox_effects=()): """ Play a speech. """ # build the segments preloader_threads = [] if self.text != "-": segments = list(self) # start preloader thread(s) preloader_threads = [PreloaderThread(name="PreloaderThread-%u" % (i)) for i in range(PRELOADER_THREAD_COUNT)] ...
python
def play(self, sox_effects=()): """ Play a speech. """ # build the segments preloader_threads = [] if self.text != "-": segments = list(self) # start preloader thread(s) preloader_threads = [PreloaderThread(name="PreloaderThread-%u" % (i)) for i in range(PRELOADER_THREAD_COUNT)] ...
[ "def", "play", "(", "self", ",", "sox_effects", "=", "(", ")", ")", ":", "preloader_threads", "=", "[", "]", "if", "self", ".", "text", "!=", "\"-\"", ":", "segments", "=", "list", "(", "self", ")", "preloader_threads", "=", "[", "PreloaderThread", "("...
Play a speech.
[ "Play", "a", "speech", "." ]
6d3ec62dc26400ccb4f2e77b8ccd4cb416141233
https://github.com/desbma/GoogleSpeech/blob/6d3ec62dc26400ccb4f2e77b8ccd4cb416141233/google_speech/__init__.py#L138-L160
train
desbma/GoogleSpeech
google_speech/__init__.py
SpeechSegment.isInCache
def isInCache(self): """ Return True if audio data for this segment is present in cache, False otherwise. """ url = self.buildUrl(cache_friendly=True) return url in __class__.cache
python
def isInCache(self): """ Return True if audio data for this segment is present in cache, False otherwise. """ url = self.buildUrl(cache_friendly=True) return url in __class__.cache
[ "def", "isInCache", "(", "self", ")", ":", "url", "=", "self", ".", "buildUrl", "(", "cache_friendly", "=", "True", ")", "return", "url", "in", "__class__", ".", "cache" ]
Return True if audio data for this segment is present in cache, False otherwise.
[ "Return", "True", "if", "audio", "data", "for", "this", "segment", "is", "present", "in", "cache", "False", "otherwise", "." ]
6d3ec62dc26400ccb4f2e77b8ccd4cb416141233
https://github.com/desbma/GoogleSpeech/blob/6d3ec62dc26400ccb4f2e77b8ccd4cb416141233/google_speech/__init__.py#L207-L210
train
desbma/GoogleSpeech
google_speech/__init__.py
SpeechSegment.preLoad
def preLoad(self): """ Store audio data in cache for fast playback. """ logging.getLogger().debug("Preloading segment '%s'" % (self)) real_url = self.buildUrl() cache_url = self.buildUrl(cache_friendly=True) audio_data = self.download(real_url) assert(audio_data) __class__.cache[cache_url] =...
python
def preLoad(self): """ Store audio data in cache for fast playback. """ logging.getLogger().debug("Preloading segment '%s'" % (self)) real_url = self.buildUrl() cache_url = self.buildUrl(cache_friendly=True) audio_data = self.download(real_url) assert(audio_data) __class__.cache[cache_url] =...
[ "def", "preLoad", "(", "self", ")", ":", "logging", ".", "getLogger", "(", ")", ".", "debug", "(", "\"Preloading segment '%s'\"", "%", "(", "self", ")", ")", "real_url", "=", "self", ".", "buildUrl", "(", ")", "cache_url", "=", "self", ".", "buildUrl", ...
Store audio data in cache for fast playback.
[ "Store", "audio", "data", "in", "cache", "for", "fast", "playback", "." ]
6d3ec62dc26400ccb4f2e77b8ccd4cb416141233
https://github.com/desbma/GoogleSpeech/blob/6d3ec62dc26400ccb4f2e77b8ccd4cb416141233/google_speech/__init__.py#L212-L219
train
desbma/GoogleSpeech
google_speech/__init__.py
SpeechSegment.getAudioData
def getAudioData(self): """ Fetch the audio data. """ with self.preload_mutex: cache_url = self.buildUrl(cache_friendly=True) if cache_url in __class__.cache: logging.getLogger().debug("Got data for URL '%s' from cache" % (cache_url)) audio_data = __class__.cache[cache_url] a...
python
def getAudioData(self): """ Fetch the audio data. """ with self.preload_mutex: cache_url = self.buildUrl(cache_friendly=True) if cache_url in __class__.cache: logging.getLogger().debug("Got data for URL '%s' from cache" % (cache_url)) audio_data = __class__.cache[cache_url] a...
[ "def", "getAudioData", "(", "self", ")", ":", "with", "self", ".", "preload_mutex", ":", "cache_url", "=", "self", ".", "buildUrl", "(", "cache_friendly", "=", "True", ")", "if", "cache_url", "in", "__class__", ".", "cache", ":", "logging", ".", "getLogger...
Fetch the audio data.
[ "Fetch", "the", "audio", "data", "." ]
6d3ec62dc26400ccb4f2e77b8ccd4cb416141233
https://github.com/desbma/GoogleSpeech/blob/6d3ec62dc26400ccb4f2e77b8ccd4cb416141233/google_speech/__init__.py#L221-L234
train
desbma/GoogleSpeech
google_speech/__init__.py
SpeechSegment.play
def play(self, sox_effects=()): """ Play the segment. """ audio_data = self.getAudioData() logging.getLogger().info("Playing speech segment (%s): '%s'" % (self.lang, self)) cmd = ["sox", "-q", "-t", "mp3", "-"] if sys.platform.startswith("win32"): cmd.extend(("-t", "waveaudio")) cmd.extend...
python
def play(self, sox_effects=()): """ Play the segment. """ audio_data = self.getAudioData() logging.getLogger().info("Playing speech segment (%s): '%s'" % (self.lang, self)) cmd = ["sox", "-q", "-t", "mp3", "-"] if sys.platform.startswith("win32"): cmd.extend(("-t", "waveaudio")) cmd.extend...
[ "def", "play", "(", "self", ",", "sox_effects", "=", "(", ")", ")", ":", "audio_data", "=", "self", ".", "getAudioData", "(", ")", "logging", ".", "getLogger", "(", ")", ".", "info", "(", "\"Playing speech segment (%s): '%s'\"", "%", "(", "self", ".", "l...
Play the segment.
[ "Play", "the", "segment", "." ]
6d3ec62dc26400ccb4f2e77b8ccd4cb416141233
https://github.com/desbma/GoogleSpeech/blob/6d3ec62dc26400ccb4f2e77b8ccd4cb416141233/google_speech/__init__.py#L236-L252
train
desbma/GoogleSpeech
google_speech/__init__.py
SpeechSegment.buildUrl
def buildUrl(self, cache_friendly=False): """ Construct the URL to get the sound from Goggle API. If cache_friendly is True, remove token from URL to use as a cache key. """ params = collections.OrderedDict() params["client"] = "tw-ob" params["ie"] = "UTF-8" params["idx"] = str(self.seg...
python
def buildUrl(self, cache_friendly=False): """ Construct the URL to get the sound from Goggle API. If cache_friendly is True, remove token from URL to use as a cache key. """ params = collections.OrderedDict() params["client"] = "tw-ob" params["ie"] = "UTF-8" params["idx"] = str(self.seg...
[ "def", "buildUrl", "(", "self", ",", "cache_friendly", "=", "False", ")", ":", "params", "=", "collections", ".", "OrderedDict", "(", ")", "params", "[", "\"client\"", "]", "=", "\"tw-ob\"", "params", "[", "\"ie\"", "]", "=", "\"UTF-8\"", "params", "[", ...
Construct the URL to get the sound from Goggle API. If cache_friendly is True, remove token from URL to use as a cache key.
[ "Construct", "the", "URL", "to", "get", "the", "sound", "from", "Goggle", "API", "." ]
6d3ec62dc26400ccb4f2e77b8ccd4cb416141233
https://github.com/desbma/GoogleSpeech/blob/6d3ec62dc26400ccb4f2e77b8ccd4cb416141233/google_speech/__init__.py#L254-L270
train
desbma/GoogleSpeech
google_speech/__init__.py
SpeechSegment.download
def download(self, url): """ Download a sound file. """ logging.getLogger().debug("Downloading '%s'..." % (url)) response = __class__.session.get(url, headers={"User-Agent": "Mozilla/5.0"}, timeout=3.1) response.raise_for_status()...
python
def download(self, url): """ Download a sound file. """ logging.getLogger().debug("Downloading '%s'..." % (url)) response = __class__.session.get(url, headers={"User-Agent": "Mozilla/5.0"}, timeout=3.1) response.raise_for_status()...
[ "def", "download", "(", "self", ",", "url", ")", ":", "logging", ".", "getLogger", "(", ")", ".", "debug", "(", "\"Downloading '%s'...\"", "%", "(", "url", ")", ")", "response", "=", "__class__", ".", "session", ".", "get", "(", "url", ",", "headers", ...
Download a sound file.
[ "Download", "a", "sound", "file", "." ]
6d3ec62dc26400ccb4f2e77b8ccd4cb416141233
https://github.com/desbma/GoogleSpeech/blob/6d3ec62dc26400ccb4f2e77b8ccd4cb416141233/google_speech/__init__.py#L272-L279
train
gtalarico/airtable-python-wrapper
airtable/params.py
_BaseObjectArrayParam.to_param_dict
def to_param_dict(self): """ Sorts to ensure Order is consistent for Testing """ param_dict = {} for index, dictionary in enumerate(self.value): for key, value in dictionary.items(): param_name = '{param_name}[{index}][{key}]'.format( ...
python
def to_param_dict(self): """ Sorts to ensure Order is consistent for Testing """ param_dict = {} for index, dictionary in enumerate(self.value): for key, value in dictionary.items(): param_name = '{param_name}[{index}][{key}]'.format( ...
[ "def", "to_param_dict", "(", "self", ")", ":", "param_dict", "=", "{", "}", "for", "index", ",", "dictionary", "in", "enumerate", "(", "self", ".", "value", ")", ":", "for", "key", ",", "value", "in", "dictionary", ".", "items", "(", ")", ":", "param...
Sorts to ensure Order is consistent for Testing
[ "Sorts", "to", "ensure", "Order", "is", "consistent", "for", "Testing" ]
48b2d806178085b52a31817571e5a1fc3dce4045
https://github.com/gtalarico/airtable-python-wrapper/blob/48b2d806178085b52a31817571e5a1fc3dce4045/airtable/params.py#L68-L78
train
gtalarico/airtable-python-wrapper
airtable/params.py
AirtableParams._get
def _get(cls, kwarg_name): """ Returns a Param Class Instance, by its kwarg or param name """ param_classes = cls._discover_params() try: param_class = param_classes[kwarg_name] except KeyError: raise ValueError('invalid param keyword {}'.format(kwarg_name))...
python
def _get(cls, kwarg_name): """ Returns a Param Class Instance, by its kwarg or param name """ param_classes = cls._discover_params() try: param_class = param_classes[kwarg_name] except KeyError: raise ValueError('invalid param keyword {}'.format(kwarg_name))...
[ "def", "_get", "(", "cls", ",", "kwarg_name", ")", ":", "param_classes", "=", "cls", ".", "_discover_params", "(", ")", "try", ":", "param_class", "=", "param_classes", "[", "kwarg_name", "]", "except", "KeyError", ":", "raise", "ValueError", "(", "'invalid ...
Returns a Param Class Instance, by its kwarg or param name
[ "Returns", "a", "Param", "Class", "Instance", "by", "its", "kwarg", "or", "param", "name" ]
48b2d806178085b52a31817571e5a1fc3dce4045
https://github.com/gtalarico/airtable-python-wrapper/blob/48b2d806178085b52a31817571e5a1fc3dce4045/airtable/params.py#L362-L370
train
gtalarico/airtable-python-wrapper
airtable/airtable.py
Airtable._process_params
def _process_params(self, params): """ Process params names or values as needed using filters """ new_params = OrderedDict() for param_name, param_value in sorted(params.items()): param_value = params[param_name] ParamClass = AirtableParams._get(par...
python
def _process_params(self, params): """ Process params names or values as needed using filters """ new_params = OrderedDict() for param_name, param_value in sorted(params.items()): param_value = params[param_name] ParamClass = AirtableParams._get(par...
[ "def", "_process_params", "(", "self", ",", "params", ")", ":", "new_params", "=", "OrderedDict", "(", ")", "for", "param_name", ",", "param_value", "in", "sorted", "(", "params", ".", "items", "(", ")", ")", ":", "param_value", "=", "params", "[", "para...
Process params names or values as needed using filters
[ "Process", "params", "names", "or", "values", "as", "needed", "using", "filters" ]
48b2d806178085b52a31817571e5a1fc3dce4045
https://github.com/gtalarico/airtable-python-wrapper/blob/48b2d806178085b52a31817571e5a1fc3dce4045/airtable/airtable.py#L141-L150
train
gtalarico/airtable-python-wrapper
airtable/airtable.py
Airtable._batch_request
def _batch_request(self, func, iterable): """ Internal Function to limit batch calls to API limit """ responses = [] for item in iterable: responses.append(func(item)) time.sleep(self.API_LIMIT) return responses
python
def _batch_request(self, func, iterable): """ Internal Function to limit batch calls to API limit """ responses = [] for item in iterable: responses.append(func(item)) time.sleep(self.API_LIMIT) return responses
[ "def", "_batch_request", "(", "self", ",", "func", ",", "iterable", ")", ":", "responses", "=", "[", "]", "for", "item", "in", "iterable", ":", "responses", ".", "append", "(", "func", "(", "item", ")", ")", "time", ".", "sleep", "(", "self", ".", ...
Internal Function to limit batch calls to API limit
[ "Internal", "Function", "to", "limit", "batch", "calls", "to", "API", "limit" ]
48b2d806178085b52a31817571e5a1fc3dce4045
https://github.com/gtalarico/airtable-python-wrapper/blob/48b2d806178085b52a31817571e5a1fc3dce4045/airtable/airtable.py#L372-L378
train
siznax/wptools
wptools/category.py
WPToolsCategory._add_members
def _add_members(self, catmembers): """ Adds category members and subcategories to data """ members = [x for x in catmembers if x['ns'] == 0] subcats = [x for x in catmembers if x['ns'] == 14] if 'members' in self.data: self.data['members'].extend(members) ...
python
def _add_members(self, catmembers): """ Adds category members and subcategories to data """ members = [x for x in catmembers if x['ns'] == 0] subcats = [x for x in catmembers if x['ns'] == 14] if 'members' in self.data: self.data['members'].extend(members) ...
[ "def", "_add_members", "(", "self", ",", "catmembers", ")", ":", "members", "=", "[", "x", "for", "x", "in", "catmembers", "if", "x", "[", "'ns'", "]", "==", "0", "]", "subcats", "=", "[", "x", "for", "x", "in", "catmembers", "if", "x", "[", "'ns...
Adds category members and subcategories to data
[ "Adds", "category", "members", "and", "subcategories", "to", "data" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/category.py#L74-L90
train
siznax/wptools
wptools/category.py
WPToolsCategory._query
def _query(self, action, qobj): """ Form query to enumerate category """ title = self.params.get('title') pageid = self.params.get('pageid') if action == 'random': return qobj.random(namespace=14) elif action == 'category': return qobj.cat...
python
def _query(self, action, qobj): """ Form query to enumerate category """ title = self.params.get('title') pageid = self.params.get('pageid') if action == 'random': return qobj.random(namespace=14) elif action == 'category': return qobj.cat...
[ "def", "_query", "(", "self", ",", "action", ",", "qobj", ")", ":", "title", "=", "self", ".", "params", ".", "get", "(", "'title'", ")", "pageid", "=", "self", ".", "params", ".", "get", "(", "'pageid'", ")", "if", "action", "==", "'random'", ":",...
Form query to enumerate category
[ "Form", "query", "to", "enumerate", "category" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/category.py#L92-L102
train
siznax/wptools
wptools/category.py
WPToolsCategory._set_data
def _set_data(self, action): """ Set category member data from API response """ data = self._load_response(action) self._handle_continuations(data, 'category') if action == 'category': members = data.get('query').get('categorymembers') if members...
python
def _set_data(self, action): """ Set category member data from API response """ data = self._load_response(action) self._handle_continuations(data, 'category') if action == 'category': members = data.get('query').get('categorymembers') if members...
[ "def", "_set_data", "(", "self", ",", "action", ")", ":", "data", "=", "self", ".", "_load_response", "(", "action", ")", "self", ".", "_handle_continuations", "(", "data", ",", "'category'", ")", "if", "action", "==", "'category'", ":", "members", "=", ...
Set category member data from API response
[ "Set", "category", "member", "data", "from", "API", "response" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/category.py#L104-L122
train
siznax/wptools
wptools/site.py
WPToolsSite._sitelist
def _sitelist(self, matrix): """ Returns a list of sites from a SiteMatrix, optionally filtered by 'domain' param """ _list = [] for item in matrix: sites = [] if isinstance(matrix[item], list): sites = matrix[item] eli...
python
def _sitelist(self, matrix): """ Returns a list of sites from a SiteMatrix, optionally filtered by 'domain' param """ _list = [] for item in matrix: sites = [] if isinstance(matrix[item], list): sites = matrix[item] eli...
[ "def", "_sitelist", "(", "self", ",", "matrix", ")", ":", "_list", "=", "[", "]", "for", "item", "in", "matrix", ":", "sites", "=", "[", "]", "if", "isinstance", "(", "matrix", "[", "item", "]", ",", "list", ")", ":", "sites", "=", "matrix", "[",...
Returns a list of sites from a SiteMatrix, optionally filtered by 'domain' param
[ "Returns", "a", "list", "of", "sites", "from", "a", "SiteMatrix", "optionally", "filtered", "by", "domain", "param" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/site.py#L125-L149
train
siznax/wptools
wptools/core.py
handle_wikidata_errors
def handle_wikidata_errors(data, query): """ Raises LookupError if wikidata error found """ entities = data.get('entities') if not entities: raise LookupError(query) elif '-1' in entities: raise LookupError(query) else: item = list(entities.values())[0] if 'm...
python
def handle_wikidata_errors(data, query): """ Raises LookupError if wikidata error found """ entities = data.get('entities') if not entities: raise LookupError(query) elif '-1' in entities: raise LookupError(query) else: item = list(entities.values())[0] if 'm...
[ "def", "handle_wikidata_errors", "(", "data", ",", "query", ")", ":", "entities", "=", "data", ".", "get", "(", "'entities'", ")", "if", "not", "entities", ":", "raise", "LookupError", "(", "query", ")", "elif", "'-1'", "in", "entities", ":", "raise", "L...
Raises LookupError if wikidata error found
[ "Raises", "LookupError", "if", "wikidata", "error", "found" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/core.py#L294-L308
train
siznax/wptools
wptools/core.py
prettyprint
def prettyprint(datastr): """ Print page data strings to stderr """ maxwidth = WPToolsQuery.MAXWIDTH rpad = WPToolsQuery.RPAD extent = maxwidth - (rpad + 2) for line in datastr: if len(line) >= maxwidth: line = line[:extent] + '...' utils.stderr(line)
python
def prettyprint(datastr): """ Print page data strings to stderr """ maxwidth = WPToolsQuery.MAXWIDTH rpad = WPToolsQuery.RPAD extent = maxwidth - (rpad + 2) for line in datastr: if len(line) >= maxwidth: line = line[:extent] + '...' utils.stderr(line)
[ "def", "prettyprint", "(", "datastr", ")", ":", "maxwidth", "=", "WPToolsQuery", ".", "MAXWIDTH", "rpad", "=", "WPToolsQuery", ".", "RPAD", "extent", "=", "maxwidth", "-", "(", "rpad", "+", "2", ")", "for", "line", "in", "datastr", ":", "if", "len", "(...
Print page data strings to stderr
[ "Print", "page", "data", "strings", "to", "stderr" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/core.py#L311-L322
train
siznax/wptools
wptools/core.py
WPTools._continue_params
def _continue_params(self): """ Returns query string fragment continue parameters """ if not self.data.get('continue'): return params = [] for item in self.data['continue']: params.append("&%s=%s" % (item, self.data['continue'][item])) re...
python
def _continue_params(self): """ Returns query string fragment continue parameters """ if not self.data.get('continue'): return params = [] for item in self.data['continue']: params.append("&%s=%s" % (item, self.data['continue'][item])) re...
[ "def", "_continue_params", "(", "self", ")", ":", "if", "not", "self", ".", "data", ".", "get", "(", "'continue'", ")", ":", "return", "params", "=", "[", "]", "for", "item", "in", "self", ".", "data", "[", "'continue'", "]", ":", "params", ".", "a...
Returns query string fragment continue parameters
[ "Returns", "query", "string", "fragment", "continue", "parameters" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/core.py#L107-L118
train
siznax/wptools
wptools/core.py
WPTools._handle_continuations
def _handle_continuations(self, response, cache_key): """ Select continue params and clear cache or last continue params """ rcontinue = response.get('continue') listen = ['blcontinue', 'cmcontinue', 'plcontinue'] cparams = {} if rcontinue: for flag i...
python
def _handle_continuations(self, response, cache_key): """ Select continue params and clear cache or last continue params """ rcontinue = response.get('continue') listen = ['blcontinue', 'cmcontinue', 'plcontinue'] cparams = {} if rcontinue: for flag i...
[ "def", "_handle_continuations", "(", "self", ",", "response", ",", "cache_key", ")", ":", "rcontinue", "=", "response", ".", "get", "(", "'continue'", ")", "listen", "=", "[", "'blcontinue'", ",", "'cmcontinue'", ",", "'plcontinue'", "]", "cparams", "=", "{"...
Select continue params and clear cache or last continue params
[ "Select", "continue", "params", "and", "clear", "cache", "or", "last", "continue", "params" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/core.py#L120-L138
train
siznax/wptools
wptools/core.py
WPTools._get
def _get(self, action, show, proxy, timeout): """ make HTTP request and cache response """ silent = self.flags['silent'] if action in self.cache: if action != 'imageinfo' and action != 'labels': utils.stderr("+ %s results in cache" % action, silent) ...
python
def _get(self, action, show, proxy, timeout): """ make HTTP request and cache response """ silent = self.flags['silent'] if action in self.cache: if action != 'imageinfo' and action != 'labels': utils.stderr("+ %s results in cache" % action, silent) ...
[ "def", "_get", "(", "self", ",", "action", ",", "show", ",", "proxy", ",", "timeout", ")", ":", "silent", "=", "self", ".", "flags", "[", "'silent'", "]", "if", "action", "in", "self", ".", "cache", ":", "if", "action", "!=", "'imageinfo'", "and", ...
make HTTP request and cache response
[ "make", "HTTP", "request", "and", "cache", "response" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/core.py#L140-L186
train
siznax/wptools
wptools/core.py
WPTools._load_response
def _load_response(self, action): """ returns API reponse from cache or raises ValueError """ _query = self.cache[action]['query'].replace('&format=json', '') response = self.cache[action]['response'] if not response: raise ValueError("Empty response: %s" % s...
python
def _load_response(self, action): """ returns API reponse from cache or raises ValueError """ _query = self.cache[action]['query'].replace('&format=json', '') response = self.cache[action]['response'] if not response: raise ValueError("Empty response: %s" % s...
[ "def", "_load_response", "(", "self", ",", "action", ")", ":", "_query", "=", "self", ".", "cache", "[", "action", "]", "[", "'query'", "]", ".", "replace", "(", "'&format=json'", ",", "''", ")", "response", "=", "self", ".", "cache", "[", "action", ...
returns API reponse from cache or raises ValueError
[ "returns", "API", "reponse", "from", "cache", "or", "raises", "ValueError" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/core.py#L188-L224
train
siznax/wptools
wptools/core.py
WPTools._request
def _request(self, proxy, timeout): """ Returns WPToolsRequest object """ return request.WPToolsRequest(self.flags['silent'], self.flags['verbose'], proxy, timeout)
python
def _request(self, proxy, timeout): """ Returns WPToolsRequest object """ return request.WPToolsRequest(self.flags['silent'], self.flags['verbose'], proxy, timeout)
[ "def", "_request", "(", "self", ",", "proxy", ",", "timeout", ")", ":", "return", "request", ".", "WPToolsRequest", "(", "self", ".", "flags", "[", "'silent'", "]", ",", "self", ".", "flags", "[", "'verbose'", "]", ",", "proxy", ",", "timeout", ")" ]
Returns WPToolsRequest object
[ "Returns", "WPToolsRequest", "object" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/core.py#L232-L238
train
siznax/wptools
wptools/core.py
WPTools.info
def info(self, action=None): """ returns cached request info for given action, or list of cached actions """ if action in self.cache: return self.cache[action]['info'] return self.cache.keys() or None
python
def info(self, action=None): """ returns cached request info for given action, or list of cached actions """ if action in self.cache: return self.cache[action]['info'] return self.cache.keys() or None
[ "def", "info", "(", "self", ",", "action", "=", "None", ")", ":", "if", "action", "in", "self", ".", "cache", ":", "return", "self", ".", "cache", "[", "action", "]", "[", "'info'", "]", "return", "self", ".", "cache", ".", "keys", "(", ")", "or"...
returns cached request info for given action, or list of cached actions
[ "returns", "cached", "request", "info", "for", "given", "action", "or", "list", "of", "cached", "actions" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/core.py#L246-L253
train
siznax/wptools
wptools/core.py
WPTools.show
def show(self): """ Pretty-print instance data """ if not self.data: return if self.data.get('continue'): return ptitle = self.params.get('title') dtitle = self.data.get('title') pageid = self.params.get('pageid') seed = ...
python
def show(self): """ Pretty-print instance data """ if not self.data: return if self.data.get('continue'): return ptitle = self.params.get('title') dtitle = self.data.get('title') pageid = self.params.get('pageid') seed = ...
[ "def", "show", "(", "self", ")", ":", "if", "not", "self", ".", "data", ":", "return", "if", "self", ".", "data", ".", "get", "(", "'continue'", ")", ":", "return", "ptitle", "=", "self", ".", "params", ".", "get", "(", "'title'", ")", "dtitle", ...
Pretty-print instance data
[ "Pretty", "-", "print", "instance", "data" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/core.py#L273-L291
train
siznax/wptools
wptools/wikidata.py
WPToolsWikidata._get_entity_prop
def _get_entity_prop(self, entity, prop): """ returns Wikidata entity property value """ variant = self.params.get('variant') lang = self.params.get('lang') if entity.get(prop): ent = entity[prop] try: return ent[variant or lang].g...
python
def _get_entity_prop(self, entity, prop): """ returns Wikidata entity property value """ variant = self.params.get('variant') lang = self.params.get('lang') if entity.get(prop): ent = entity[prop] try: return ent[variant or lang].g...
[ "def", "_get_entity_prop", "(", "self", ",", "entity", ",", "prop", ")", ":", "variant", "=", "self", ".", "params", ".", "get", "(", "'variant'", ")", "lang", "=", "self", ".", "params", ".", "get", "(", "'lang'", ")", "if", "entity", ".", "get", ...
returns Wikidata entity property value
[ "returns", "Wikidata", "entity", "property", "value" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/wikidata.py#L49-L61
train
siznax/wptools
wptools/wikidata.py
WPToolsWikidata._marshal_claims
def _marshal_claims(self, query_claims): """ set Wikidata entities from query claims """ claims = reduce_claims(query_claims) # self.data['claimq'] = query_claims self.data['claims'] = claims entities = set() for eid in claims: if self.user_la...
python
def _marshal_claims(self, query_claims): """ set Wikidata entities from query claims """ claims = reduce_claims(query_claims) # self.data['claimq'] = query_claims self.data['claims'] = claims entities = set() for eid in claims: if self.user_la...
[ "def", "_marshal_claims", "(", "self", ",", "query_claims", ")", ":", "claims", "=", "reduce_claims", "(", "query_claims", ")", "self", ".", "data", "[", "'claims'", "]", "=", "claims", "entities", "=", "set", "(", ")", "for", "eid", "in", "claims", ":",...
set Wikidata entities from query claims
[ "set", "Wikidata", "entities", "from", "query", "claims" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/wikidata.py#L63-L85
train
siznax/wptools
wptools/wikidata.py
WPToolsWikidata._pop_entities
def _pop_entities(self, limit=50): """ returns up to limit entities and pops them off the list """ pop = self.data['entities'][:limit] del self.data['entities'][:limit] return pop
python
def _pop_entities(self, limit=50): """ returns up to limit entities and pops them off the list """ pop = self.data['entities'][:limit] del self.data['entities'][:limit] return pop
[ "def", "_pop_entities", "(", "self", ",", "limit", "=", "50", ")", ":", "pop", "=", "self", ".", "data", "[", "'entities'", "]", "[", ":", "limit", "]", "del", "self", ".", "data", "[", "'entities'", "]", "[", ":", "limit", "]", "return", "pop" ]
returns up to limit entities and pops them off the list
[ "returns", "up", "to", "limit", "entities", "and", "pops", "them", "off", "the", "list" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/wikidata.py#L87-L93
train
siznax/wptools
wptools/wikidata.py
WPToolsWikidata._query
def _query(self, action, qobj): """ returns wikidata query string """ if action == 'labels': return qobj.labels(self._pop_entities()) elif action == 'wikidata': return qobj.wikidata(self.params.get('title'), self.params.get...
python
def _query(self, action, qobj): """ returns wikidata query string """ if action == 'labels': return qobj.labels(self._pop_entities()) elif action == 'wikidata': return qobj.wikidata(self.params.get('title'), self.params.get...
[ "def", "_query", "(", "self", ",", "action", ",", "qobj", ")", ":", "if", "action", "==", "'labels'", ":", "return", "qobj", ".", "labels", "(", "self", ".", "_pop_entities", "(", ")", ")", "elif", "action", "==", "'wikidata'", ":", "return", "qobj", ...
returns wikidata query string
[ "returns", "wikidata", "query", "string" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/wikidata.py#L103-L111
train
siznax/wptools
wptools/wikidata.py
WPToolsWikidata._set_title
def _set_title(self, item): """ attempt to set title from wikidata """ title = None lang = self.params['lang'] label = self.data['label'] if item.get('sitelinks'): for link in item['sitelinks']: if link == "%swiki" % lang: ...
python
def _set_title(self, item): """ attempt to set title from wikidata """ title = None lang = self.params['lang'] label = self.data['label'] if item.get('sitelinks'): for link in item['sitelinks']: if link == "%swiki" % lang: ...
[ "def", "_set_title", "(", "self", ",", "item", ")", ":", "title", "=", "None", "lang", "=", "self", ".", "params", "[", "'lang'", "]", "label", "=", "self", ".", "data", "[", "'label'", "]", "if", "item", ".", "get", "(", "'sitelinks'", ")", ":", ...
attempt to set title from wikidata
[ "attempt", "to", "set", "title", "from", "wikidata" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/wikidata.py#L135-L153
train
siznax/wptools
wptools/wikidata.py
WPToolsWikidata._update_images
def _update_images(self): """ add images from Wikidata """ wd_images = self.data['claims'].get('P18') # image if wd_images: if not isinstance(wd_images, list): wd_images = [wd_images] if 'image' not in self.data: self.dat...
python
def _update_images(self): """ add images from Wikidata """ wd_images = self.data['claims'].get('P18') # image if wd_images: if not isinstance(wd_images, list): wd_images = [wd_images] if 'image' not in self.data: self.dat...
[ "def", "_update_images", "(", "self", ")", ":", "wd_images", "=", "self", ".", "data", "[", "'claims'", "]", ".", "get", "(", "'P18'", ")", "if", "wd_images", ":", "if", "not", "isinstance", "(", "wd_images", ",", "list", ")", ":", "wd_images", "=", ...
add images from Wikidata
[ "add", "images", "from", "Wikidata" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/wikidata.py#L190-L205
train
siznax/wptools
wptools/wikidata.py
WPToolsWikidata._update_wikidata
def _update_wikidata(self): """ set wikidata from claims and labels """ claims = self.data['claims'] for ent in claims: plabel = self.data['labels'].get(ent) # P (property) label if plabel: plabel = "%s (%s)" % (plabel, ent) ...
python
def _update_wikidata(self): """ set wikidata from claims and labels """ claims = self.data['claims'] for ent in claims: plabel = self.data['labels'].get(ent) # P (property) label if plabel: plabel = "%s (%s)" % (plabel, ent) ...
[ "def", "_update_wikidata", "(", "self", ")", ":", "claims", "=", "self", ".", "data", "[", "'claims'", "]", "for", "ent", "in", "claims", ":", "plabel", "=", "self", ".", "data", "[", "'labels'", "]", ".", "get", "(", "ent", ")", "if", "plabel", ":...
set wikidata from claims and labels
[ "set", "wikidata", "from", "claims", "and", "labels" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/wikidata.py#L223-L249
train
siznax/wptools
scripts/wptool.py
_html_image
def _html_image(page): """ returns HTML img tag """ source = _image(page) if not source: return alt = page.data.get('label') or page.data.get('title') img = "<img src=\"%s\"" % source img += " alt=\"%s\" title=\"%s\" " % (alt, alt) img += "align=\"right\" width=\"240\">" ...
python
def _html_image(page): """ returns HTML img tag """ source = _image(page) if not source: return alt = page.data.get('label') or page.data.get('title') img = "<img src=\"%s\"" % source img += " alt=\"%s\" title=\"%s\" " % (alt, alt) img += "align=\"right\" width=\"240\">" ...
[ "def", "_html_image", "(", "page", ")", ":", "source", "=", "_image", "(", "page", ")", "if", "not", "source", ":", "return", "alt", "=", "page", ".", "data", ".", "get", "(", "'label'", ")", "or", "page", ".", "data", ".", "get", "(", "'title'", ...
returns HTML img tag
[ "returns", "HTML", "img", "tag" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/scripts/wptool.py#L19-L30
train
siznax/wptools
scripts/wptool.py
_html_title
def _html_title(page): """ returns Wiki-linked HTML title """ link = "<a href=\"%s\">%s</a>" % (page.data.get('url'), page.data.get('title')) desc = page.data.get('description') if desc: link += "&mdash;<i>%s</i>" % desc else: link += "&m...
python
def _html_title(page): """ returns Wiki-linked HTML title """ link = "<a href=\"%s\">%s</a>" % (page.data.get('url'), page.data.get('title')) desc = page.data.get('description') if desc: link += "&mdash;<i>%s</i>" % desc else: link += "&m...
[ "def", "_html_title", "(", "page", ")", ":", "link", "=", "\"<a href=\\\"%s\\\">%s</a>\"", "%", "(", "page", ".", "data", ".", "get", "(", "'url'", ")", ",", "page", ".", "data", ".", "get", "(", "'title'", ")", ")", "desc", "=", "page", ".", "data",...
returns Wiki-linked HTML title
[ "returns", "Wiki", "-", "linked", "HTML", "title" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/scripts/wptool.py#L33-L45
train
siznax/wptools
scripts/wptool.py
_page_html
def _page_html(page): """ returns assembled HTML output """ out = [] out.append(_html_title(page)) out.append(_html_image(page)) out.append(page.data.get('extract')) return "\n".join([x for x in out if x])
python
def _page_html(page): """ returns assembled HTML output """ out = [] out.append(_html_title(page)) out.append(_html_image(page)) out.append(page.data.get('extract')) return "\n".join([x for x in out if x])
[ "def", "_page_html", "(", "page", ")", ":", "out", "=", "[", "]", "out", ".", "append", "(", "_html_title", "(", "page", ")", ")", "out", ".", "append", "(", "_html_image", "(", "page", ")", ")", "out", ".", "append", "(", "page", ".", "data", "....
returns assembled HTML output
[ "returns", "assembled", "HTML", "output" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/scripts/wptool.py#L57-L65
train
siznax/wptools
scripts/wptool.py
_page_text
def _page_text(page, nowrap=False): """ returns assembled text output """ title = page.data['title'] title = "%s\n%s" % (title, "=" * len(title)) desc = page.data.get('description') if desc: desc = "_%s_" % desc img = _text_image(page) pars = page.data.get('extext') i...
python
def _page_text(page, nowrap=False): """ returns assembled text output """ title = page.data['title'] title = "%s\n%s" % (title, "=" * len(title)) desc = page.data.get('description') if desc: desc = "_%s_" % desc img = _text_image(page) pars = page.data.get('extext') i...
[ "def", "_page_text", "(", "page", ",", "nowrap", "=", "False", ")", ":", "title", "=", "page", ".", "data", "[", "'title'", "]", "title", "=", "\"%s\\n%s\"", "%", "(", "title", ",", "\"=\"", "*", "len", "(", "title", ")", ")", "desc", "=", "page", ...
returns assembled text output
[ "returns", "assembled", "text", "output" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/scripts/wptool.py#L68-L107
train
siznax/wptools
scripts/wptool.py
_safe_exit
def _safe_exit(start, output): """ exit without breaking pipes """ try: sys.stdout.write(output) sys.stdout.flush() except TypeError: # python3 sys.stdout.write(str(output, 'utf-8')) sys.stdout.flush() except IOError: pass seconds = time.time() - sta...
python
def _safe_exit(start, output): """ exit without breaking pipes """ try: sys.stdout.write(output) sys.stdout.flush() except TypeError: # python3 sys.stdout.write(str(output, 'utf-8')) sys.stdout.flush() except IOError: pass seconds = time.time() - sta...
[ "def", "_safe_exit", "(", "start", ",", "output", ")", ":", "try", ":", "sys", ".", "stdout", ".", "write", "(", "output", ")", "sys", ".", "stdout", ".", "flush", "(", ")", "except", "TypeError", ":", "sys", ".", "stdout", ".", "write", "(", "str"...
exit without breaking pipes
[ "exit", "without", "breaking", "pipes" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/scripts/wptool.py#L110-L124
train
siznax/wptools
scripts/wptool.py
_text_image
def _text_image(page): """ returns text image URL """ img = None alt = page.data.get('label') or page.data.get('title') source = _image(page) if source: img = "![%s](%s)" % (alt, source) return img
python
def _text_image(page): """ returns text image URL """ img = None alt = page.data.get('label') or page.data.get('title') source = _image(page) if source: img = "![%s](%s)" % (alt, source) return img
[ "def", "_text_image", "(", "page", ")", ":", "img", "=", "None", "alt", "=", "page", ".", "data", ".", "get", "(", "'label'", ")", "or", "page", ".", "data", ".", "get", "(", "'title'", ")", "source", "=", "_image", "(", "page", ")", "if", "sourc...
returns text image URL
[ "returns", "text", "image", "URL" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/scripts/wptool.py#L127-L136
train
siznax/wptools
scripts/wptool.py
get
def get(args): """ invoke wptools and assemble selected output """ html = args.H lang = args.l nowrap = args.n query = args.q silent = args.s title = args.t verbose = args.v wiki = args.w if query: qobj = WPToolsQuery(lang=lang, wiki=wiki) if title: ...
python
def get(args): """ invoke wptools and assemble selected output """ html = args.H lang = args.l nowrap = args.n query = args.q silent = args.s title = args.t verbose = args.v wiki = args.w if query: qobj = WPToolsQuery(lang=lang, wiki=wiki) if title: ...
[ "def", "get", "(", "args", ")", ":", "html", "=", "args", ".", "H", "lang", "=", "args", ".", "l", "nowrap", "=", "args", ".", "n", "query", "=", "args", ".", "q", "silent", "=", "args", ".", "s", "title", "=", "args", ".", "t", "verbose", "=...
invoke wptools and assemble selected output
[ "invoke", "wptools", "and", "assemble", "selected", "output" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/scripts/wptool.py#L139-L177
train
siznax/wptools
scripts/wptool.py
main
def main(args): """ invoke wptools and exit safely """ start = time.time() output = get(args) _safe_exit(start, output)
python
def main(args): """ invoke wptools and exit safely """ start = time.time() output = get(args) _safe_exit(start, output)
[ "def", "main", "(", "args", ")", ":", "start", "=", "time", ".", "time", "(", ")", "output", "=", "get", "(", "args", ")", "_safe_exit", "(", "start", ",", "output", ")" ]
invoke wptools and exit safely
[ "invoke", "wptools", "and", "exit", "safely" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/scripts/wptool.py#L213-L219
train
siznax/wptools
wptools/page.py
WPToolsPage.__insert_image_info
def __insert_image_info(self, title, _from, info): """ Insert API image INFO into matching image dict We make one imageinfo request containing only unique image filenames. We reduce duplication by asking for image data per file, instead of per "kind" or source (Wikipedia, Wikida...
python
def __insert_image_info(self, title, _from, info): """ Insert API image INFO into matching image dict We make one imageinfo request containing only unique image filenames. We reduce duplication by asking for image data per file, instead of per "kind" or source (Wikipedia, Wikida...
[ "def", "__insert_image_info", "(", "self", ",", "title", ",", "_from", ",", "info", ")", ":", "for", "img", "in", "self", ".", "data", "[", "'image'", "]", ":", "if", "'url'", "not", "in", "img", ":", "if", "title", "==", "img", "[", "'file'", "]",...
Insert API image INFO into matching image dict We make one imageinfo request containing only unique image filenames. We reduce duplication by asking for image data per file, instead of per "kind" or source (Wikipedia, Wikidata, etc.), because some sources reference the same image file. ...
[ "Insert", "API", "image", "INFO", "into", "matching", "image", "dict" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L84-L102
train
siznax/wptools
wptools/page.py
WPToolsPage.__pull_image_info
def __pull_image_info(self, title, imageinfo, normalized): """ Pull image INFO from API response and insert """ for info in imageinfo: info.update({'title': title}) # get API normalized "from" filename for matching _from = None for norm in...
python
def __pull_image_info(self, title, imageinfo, normalized): """ Pull image INFO from API response and insert """ for info in imageinfo: info.update({'title': title}) # get API normalized "from" filename for matching _from = None for norm in...
[ "def", "__pull_image_info", "(", "self", ",", "title", ",", "imageinfo", ",", "normalized", ")", ":", "for", "info", "in", "imageinfo", ":", "info", ".", "update", "(", "{", "'title'", ":", "title", "}", ")", "_from", "=", "None", "for", "norm", "in", ...
Pull image INFO from API response and insert
[ "Pull", "image", "INFO", "from", "API", "response", "and", "insert" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L104-L124
train
siznax/wptools
wptools/page.py
WPToolsPage._extend_data
def _extend_data(self, datapoint, new_data): """ extend or assign new data to datapoint """ if new_data: try: self.data[datapoint].extend(new_data) except KeyError: self.data[datapoint] = new_data
python
def _extend_data(self, datapoint, new_data): """ extend or assign new data to datapoint """ if new_data: try: self.data[datapoint].extend(new_data) except KeyError: self.data[datapoint] = new_data
[ "def", "_extend_data", "(", "self", ",", "datapoint", ",", "new_data", ")", ":", "if", "new_data", ":", "try", ":", "self", ".", "data", "[", "datapoint", "]", ".", "extend", "(", "new_data", ")", "except", "KeyError", ":", "self", ".", "data", "[", ...
extend or assign new data to datapoint
[ "extend", "or", "assign", "new", "data", "to", "datapoint" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L126-L134
train
siznax/wptools
wptools/page.py
WPToolsPage._missing_imageinfo
def _missing_imageinfo(self): """ returns list of image filenames that are missing info """ if 'image' not in self.data: return missing = [] for img in self.data['image']: if 'url' not in img: missing.append(img['file']) ret...
python
def _missing_imageinfo(self): """ returns list of image filenames that are missing info """ if 'image' not in self.data: return missing = [] for img in self.data['image']: if 'url' not in img: missing.append(img['file']) ret...
[ "def", "_missing_imageinfo", "(", "self", ")", ":", "if", "'image'", "not", "in", "self", ".", "data", ":", "return", "missing", "=", "[", "]", "for", "img", "in", "self", ".", "data", "[", "'image'", "]", ":", "if", "'url'", "not", "in", "img", ":...
returns list of image filenames that are missing info
[ "returns", "list", "of", "image", "filenames", "that", "are", "missing", "info" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L136-L146
train
siznax/wptools
wptools/page.py
WPToolsPage._query
def _query(self, action, qobj): """ returns WPToolsQuery string """ title = self.params.get('title') pageid = self.params.get('pageid') wikibase = self.params.get('wikibase') qstr = None if action == 'random': qstr = qobj.random() eli...
python
def _query(self, action, qobj): """ returns WPToolsQuery string """ title = self.params.get('title') pageid = self.params.get('pageid') wikibase = self.params.get('wikibase') qstr = None if action == 'random': qstr = qobj.random() eli...
[ "def", "_query", "(", "self", ",", "action", ",", "qobj", ")", ":", "title", "=", "self", ".", "params", ".", "get", "(", "'title'", ")", "pageid", "=", "self", ".", "params", ".", "get", "(", "'pageid'", ")", "wikibase", "=", "self", ".", "params"...
returns WPToolsQuery string
[ "returns", "WPToolsQuery", "string" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L163-L193
train
siznax/wptools
wptools/page.py
WPToolsPage._set_data
def _set_data(self, action): """ marshals response data into page data """ if 'query' in action: self._set_query_data(action) elif action == 'imageinfo': self._set_imageinfo_data() elif action == 'parse': self._set_parse_data() ...
python
def _set_data(self, action): """ marshals response data into page data """ if 'query' in action: self._set_query_data(action) elif action == 'imageinfo': self._set_imageinfo_data() elif action == 'parse': self._set_parse_data() ...
[ "def", "_set_data", "(", "self", ",", "action", ")", ":", "if", "'query'", "in", "action", ":", "self", ".", "_set_query_data", "(", "action", ")", "elif", "action", "==", "'imageinfo'", ":", "self", ".", "_set_imageinfo_data", "(", ")", "elif", "action", ...
marshals response data into page data
[ "marshals", "response", "data", "into", "page", "data" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L195-L216
train
siznax/wptools
wptools/page.py
WPToolsPage._set_parse_image
def _set_parse_image(self, infobox): """ set image data from action=parse response """ image = infobox.get('image') cover = infobox.get('Cover') or infobox.get('cover') if image or cover: if 'image' not in self.data: self.data['image'] = [] ...
python
def _set_parse_image(self, infobox): """ set image data from action=parse response """ image = infobox.get('image') cover = infobox.get('Cover') or infobox.get('cover') if image or cover: if 'image' not in self.data: self.data['image'] = [] ...
[ "def", "_set_parse_image", "(", "self", ",", "infobox", ")", ":", "image", "=", "infobox", ".", "get", "(", "'image'", ")", "cover", "=", "infobox", ".", "get", "(", "'Cover'", ")", "or", "infobox", ".", "get", "(", "'cover'", ")", "if", "image", "or...
set image data from action=parse response
[ "set", "image", "data", "from", "action", "=", "parse", "response" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L274-L289
train
siznax/wptools
wptools/page.py
WPToolsPage._set_query_data_fast_1
def _set_query_data_fast_1(self, page): """ set less expensive action=query response data PART 1 """ self.data['pageid'] = page.get('pageid') assessments = page.get('pageassessments') if assessments: self.data['assessments'] = assessments extract = p...
python
def _set_query_data_fast_1(self, page): """ set less expensive action=query response data PART 1 """ self.data['pageid'] = page.get('pageid') assessments = page.get('pageassessments') if assessments: self.data['assessments'] = assessments extract = p...
[ "def", "_set_query_data_fast_1", "(", "self", ",", "page", ")", ":", "self", ".", "data", "[", "'pageid'", "]", "=", "page", ".", "get", "(", "'pageid'", ")", "assessments", "=", "page", ".", "get", "(", "'pageassessments'", ")", "if", "assessments", ":"...
set less expensive action=query response data PART 1
[ "set", "less", "expensive", "action", "=", "query", "response", "data", "PART", "1" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L311-L349
train
siznax/wptools
wptools/page.py
WPToolsPage._set_query_data_fast_2
def _set_query_data_fast_2(self, page): """ set less expensive action=query response data PART 2 """ self.data['pageid'] = page.get('pageid') redirects = page.get('redirects') if redirects: self.data['redirects'] = redirects terms = page.get('terms')...
python
def _set_query_data_fast_2(self, page): """ set less expensive action=query response data PART 2 """ self.data['pageid'] = page.get('pageid') redirects = page.get('redirects') if redirects: self.data['redirects'] = redirects terms = page.get('terms')...
[ "def", "_set_query_data_fast_2", "(", "self", ",", "page", ")", ":", "self", ".", "data", "[", "'pageid'", "]", "=", "page", ".", "get", "(", "'pageid'", ")", "redirects", "=", "page", ".", "get", "(", "'redirects'", ")", "if", "redirects", ":", "self"...
set less expensive action=query response data PART 2
[ "set", "less", "expensive", "action", "=", "query", "response", "data", "PART", "2" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L351-L381
train
siznax/wptools
wptools/page.py
WPToolsPage._set_query_data_slow
def _set_query_data_slow(self, page): """ set more expensive action=query response data """ categories = page.get('categories') if categories: self.data['categories'] = [x['title'] for x in categories] if page.get('contributors'): contributors = p...
python
def _set_query_data_slow(self, page): """ set more expensive action=query response data """ categories = page.get('categories') if categories: self.data['categories'] = [x['title'] for x in categories] if page.get('contributors'): contributors = p...
[ "def", "_set_query_data_slow", "(", "self", ",", "page", ")", ":", "categories", "=", "page", ".", "get", "(", "'categories'", ")", "if", "categories", ":", "self", ".", "data", "[", "'categories'", "]", "=", "[", "x", "[", "'title'", "]", "for", "x", ...
set more expensive action=query response data
[ "set", "more", "expensive", "action", "=", "query", "response", "data" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L383-L412
train
siznax/wptools
wptools/page.py
WPToolsPage._set_query_image
def _set_query_image(self, page): """ set image data from action=query response """ pageimage = page.get('pageimage') thumbnail = page.get('thumbnail') if pageimage or thumbnail: if 'image' not in self.data: self.data['image'] = [] if...
python
def _set_query_image(self, page): """ set image data from action=query response """ pageimage = page.get('pageimage') thumbnail = page.get('thumbnail') if pageimage or thumbnail: if 'image' not in self.data: self.data['image'] = [] if...
[ "def", "_set_query_image", "(", "self", ",", "page", ")", ":", "pageimage", "=", "page", ".", "get", "(", "'pageimage'", ")", "thumbnail", "=", "page", ".", "get", "(", "'thumbnail'", ")", "if", "pageimage", "or", "thumbnail", ":", "if", "'image'", "not"...
set image data from action=query response
[ "set", "image", "data", "from", "action", "=", "query", "response" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L414-L436
train
siznax/wptools
wptools/page.py
WPToolsPage._set_random_data
def _set_random_data(self): """ sets page data from random request """ rdata = self._load_response('random') rdata = rdata['query']['random'][0] pageid = rdata.get('id') title = rdata.get('title') self.data.update({'pageid': pageid, ...
python
def _set_random_data(self): """ sets page data from random request """ rdata = self._load_response('random') rdata = rdata['query']['random'][0] pageid = rdata.get('id') title = rdata.get('title') self.data.update({'pageid': pageid, ...
[ "def", "_set_random_data", "(", "self", ")", ":", "rdata", "=", "self", ".", "_load_response", "(", "'random'", ")", "rdata", "=", "rdata", "[", "'query'", "]", "[", "'random'", "]", "[", "0", "]", "pageid", "=", "rdata", ".", "get", "(", "'id'", ")"...
sets page data from random request
[ "sets", "page", "data", "from", "random", "request" ]
100eaea585c34aa9ad87a9eda8982bb4898f6ec9
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L438-L449
train