repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
nirum/tableprint
tableprint/printer.py
top
def top(n, width=WIDTH, style=STYLE): """Prints the top row of a table""" return hrule(n, width, linestyle=STYLES[style].top)
python
def top(n, width=WIDTH, style=STYLE): """Prints the top row of a table""" return hrule(n, width, linestyle=STYLES[style].top)
[ "def", "top", "(", "n", ",", "width", "=", "WIDTH", ",", "style", "=", "STYLE", ")", ":", "return", "hrule", "(", "n", ",", "width", ",", "linestyle", "=", "STYLES", "[", "style", "]", ".", "top", ")" ]
Prints the top row of a table
[ "Prints", "the", "top", "row", "of", "a", "table" ]
train
https://github.com/nirum/tableprint/blob/50ab4b96706fce8ee035a4d48cb456e3271eab3d/tableprint/printer.py#L245-L247
nirum/tableprint
tableprint/printer.py
banner
def banner(message, width=30, style='banner', out=sys.stdout): """Prints a banner message Parameters ---------- message : string The message to print in the banner width : int The minimum width of the banner (Default: 30) style : string A line formatting style (Default...
python
def banner(message, width=30, style='banner', out=sys.stdout): """Prints a banner message Parameters ---------- message : string The message to print in the banner width : int The minimum width of the banner (Default: 30) style : string A line formatting style (Default...
[ "def", "banner", "(", "message", ",", "width", "=", "30", ",", "style", "=", "'banner'", ",", "out", "=", "sys", ".", "stdout", ")", ":", "out", ".", "write", "(", "header", "(", "[", "message", "]", ",", "width", "=", "max", "(", "width", ",", ...
Prints a banner message Parameters ---------- message : string The message to print in the banner width : int The minimum width of the banner (Default: 30) style : string A line formatting style (Default: 'banner') out : writer An object that has write() and f...
[ "Prints", "a", "banner", "message" ]
train
https://github.com/nirum/tableprint/blob/50ab4b96706fce8ee035a4d48cb456e3271eab3d/tableprint/printer.py#L255-L273
nirum/tableprint
tableprint/printer.py
dataframe
def dataframe(df, **kwargs): """Print table with data from the given pandas DataFrame Parameters ---------- df : DataFrame A pandas DataFrame with the table to print """ table(df.values, list(df.columns), **kwargs)
python
def dataframe(df, **kwargs): """Print table with data from the given pandas DataFrame Parameters ---------- df : DataFrame A pandas DataFrame with the table to print """ table(df.values, list(df.columns), **kwargs)
[ "def", "dataframe", "(", "df", ",", "*", "*", "kwargs", ")", ":", "table", "(", "df", ".", "values", ",", "list", "(", "df", ".", "columns", ")", ",", "*", "*", "kwargs", ")" ]
Print table with data from the given pandas DataFrame Parameters ---------- df : DataFrame A pandas DataFrame with the table to print
[ "Print", "table", "with", "data", "from", "the", "given", "pandas", "DataFrame" ]
train
https://github.com/nirum/tableprint/blob/50ab4b96706fce8ee035a4d48cb456e3271eab3d/tableprint/printer.py#L276-L284
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_address
def set_address(self, address): """ Set the address. :param address: """ self._query_params += str(QueryParam.ADVANCED) + str(QueryParam.ADDRESS) + address.replace(" ", "+").lower()
python
def set_address(self, address): """ Set the address. :param address: """ self._query_params += str(QueryParam.ADVANCED) + str(QueryParam.ADDRESS) + address.replace(" ", "+").lower()
[ "def", "set_address", "(", "self", ",", "address", ")", ":", "self", ".", "_query_params", "+=", "str", "(", "QueryParam", ".", "ADVANCED", ")", "+", "str", "(", "QueryParam", ".", "ADDRESS", ")", "+", "address", ".", "replace", "(", "\" \"", ",", "\"+...
Set the address. :param address:
[ "Set", "the", "address", ".", ":", "param", "address", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L42-L47
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_min_lease
def set_min_lease(self, min_lease): """ Set the minimum lease period in months. :param min_lease: int """ self._query_params += str(QueryParam.MIN_LEASE) + str(min_lease)
python
def set_min_lease(self, min_lease): """ Set the minimum lease period in months. :param min_lease: int """ self._query_params += str(QueryParam.MIN_LEASE) + str(min_lease)
[ "def", "set_min_lease", "(", "self", ",", "min_lease", ")", ":", "self", ".", "_query_params", "+=", "str", "(", "QueryParam", ".", "MIN_LEASE", ")", "+", "str", "(", "min_lease", ")" ]
Set the minimum lease period in months. :param min_lease: int
[ "Set", "the", "minimum", "lease", "period", "in", "months", ".", ":", "param", "min_lease", ":", "int" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L49-L54
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_added_since
def set_added_since(self, added): """ Set this to retrieve ads that are a given number of days old. For example to retrieve listings that have been been added a week ago: set_added_since(7) :param added: int """ self._query_params += str(QueryParam.DAYS_OLD) + str(added)
python
def set_added_since(self, added): """ Set this to retrieve ads that are a given number of days old. For example to retrieve listings that have been been added a week ago: set_added_since(7) :param added: int """ self._query_params += str(QueryParam.DAYS_OLD) + str(added)
[ "def", "set_added_since", "(", "self", ",", "added", ")", ":", "self", ".", "_query_params", "+=", "str", "(", "QueryParam", ".", "DAYS_OLD", ")", "+", "str", "(", "added", ")" ]
Set this to retrieve ads that are a given number of days old. For example to retrieve listings that have been been added a week ago: set_added_since(7) :param added: int
[ "Set", "this", "to", "retrieve", "ads", "that", "are", "a", "given", "number", "of", "days", "old", ".", "For", "example", "to", "retrieve", "listings", "that", "have", "been", "been", "added", "a", "week", "ago", ":", "set_added_since", "(", "7", ")", ...
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L56-L62
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_max_lease
def set_max_lease(self, max_lease): """ Set the maximum lease period in months. :param max_lease: int """ self._query_params += str(QueryParam.MAX_LEASE) + str(max_lease)
python
def set_max_lease(self, max_lease): """ Set the maximum lease period in months. :param max_lease: int """ self._query_params += str(QueryParam.MAX_LEASE) + str(max_lease)
[ "def", "set_max_lease", "(", "self", ",", "max_lease", ")", ":", "self", ".", "_query_params", "+=", "str", "(", "QueryParam", ".", "MAX_LEASE", ")", "+", "str", "(", "max_lease", ")" ]
Set the maximum lease period in months. :param max_lease: int
[ "Set", "the", "maximum", "lease", "period", "in", "months", ".", ":", "param", "max_lease", ":", "int" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L64-L69
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_availability
def set_availability(self, availability): """ Set the maximum lease period in months. :param availability: """ if availability >= 5: availability = '5%2B' self._query_params += str(QueryParam.AVALIABILITY) + str(availability)
python
def set_availability(self, availability): """ Set the maximum lease period in months. :param availability: """ if availability >= 5: availability = '5%2B' self._query_params += str(QueryParam.AVALIABILITY) + str(availability)
[ "def", "set_availability", "(", "self", ",", "availability", ")", ":", "if", "availability", ">=", "5", ":", "availability", "=", "'5%2B'", "self", ".", "_query_params", "+=", "str", "(", "QueryParam", ".", "AVALIABILITY", ")", "+", "str", "(", "availability...
Set the maximum lease period in months. :param availability:
[ "Set", "the", "maximum", "lease", "period", "in", "months", ".", ":", "param", "availability", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L71-L78
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_room_type
def set_room_type(self, room_type): """ Set the room type. :param room_type: """ if not isinstance(room_type, RoomType): raise DaftException("room_type should be an instance of RoomType.") self._query_params += str(QueryParam.ROOM_TYPE) + str(room_type)
python
def set_room_type(self, room_type): """ Set the room type. :param room_type: """ if not isinstance(room_type, RoomType): raise DaftException("room_type should be an instance of RoomType.") self._query_params += str(QueryParam.ROOM_TYPE) + str(room_type)
[ "def", "set_room_type", "(", "self", ",", "room_type", ")", ":", "if", "not", "isinstance", "(", "room_type", ",", "RoomType", ")", ":", "raise", "DaftException", "(", "\"room_type should be an instance of RoomType.\"", ")", "self", ".", "_query_params", "+=", "st...
Set the room type. :param room_type:
[ "Set", "the", "room", "type", ".", ":", "param", "room_type", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L106-L113
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_keywords
def set_keywords(self, keywords): """ Pass an array to filter the result by keywords. :param keywords """ self._query_params += str(QueryParam.KEYWORDS) + '+'.join(keywords)
python
def set_keywords(self, keywords): """ Pass an array to filter the result by keywords. :param keywords """ self._query_params += str(QueryParam.KEYWORDS) + '+'.join(keywords)
[ "def", "set_keywords", "(", "self", ",", "keywords", ")", ":", "self", ".", "_query_params", "+=", "str", "(", "QueryParam", ".", "KEYWORDS", ")", "+", "'+'", ".", "join", "(", "keywords", ")" ]
Pass an array to filter the result by keywords. :param keywords
[ "Pass", "an", "array", "to", "filter", "the", "result", "by", "keywords", ".", ":", "param", "keywords" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L123-L128
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_area
def set_area(self, area): """ The area to retrieve listings from. Use an array to search multiple areas. :param area: :return: """ self._area = area.replace(" ", "-").lower() if isinstance(area, str) else ','.join( map(lambda x: x.lower().replace(' ', '-'), ar...
python
def set_area(self, area): """ The area to retrieve listings from. Use an array to search multiple areas. :param area: :return: """ self._area = area.replace(" ", "-").lower() if isinstance(area, str) else ','.join( map(lambda x: x.lower().replace(' ', '-'), ar...
[ "def", "set_area", "(", "self", ",", "area", ")", ":", "self", ".", "_area", "=", "area", ".", "replace", "(", "\" \"", ",", "\"-\"", ")", ".", "lower", "(", ")", "if", "isinstance", "(", "area", ",", "str", ")", "else", "','", ".", "join", "(", ...
The area to retrieve listings from. Use an array to search multiple areas. :param area: :return:
[ "The", "area", "to", "retrieve", "listings", "from", ".", "Use", "an", "array", "to", "search", "multiple", "areas", ".", ":", "param", "area", ":", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L139-L146
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_open_viewing
def set_open_viewing(self, open_viewing): """ Set to True to only search for properties that have upcoming 'open for viewing' dates. :param open_viewing: :return: """ if open_viewing: self._open_viewing = open_viewing self._query_params += str(Quer...
python
def set_open_viewing(self, open_viewing): """ Set to True to only search for properties that have upcoming 'open for viewing' dates. :param open_viewing: :return: """ if open_viewing: self._open_viewing = open_viewing self._query_params += str(Quer...
[ "def", "set_open_viewing", "(", "self", ",", "open_viewing", ")", ":", "if", "open_viewing", ":", "self", ".", "_open_viewing", "=", "open_viewing", "self", ".", "_query_params", "+=", "str", "(", "QueryParam", ".", "OPEN_VIEWING", ")" ]
Set to True to only search for properties that have upcoming 'open for viewing' dates. :param open_viewing: :return:
[ "Set", "to", "True", "to", "only", "search", "for", "properties", "that", "have", "upcoming", "open", "for", "viewing", "dates", ".", ":", "param", "open_viewing", ":", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L156-L164
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_offset
def set_offset(self, offset): """ The page number which is in increments of 10. The default page number is 0. :param offset: :return: """ if not isinstance(offset, int) or offset < 0: raise DaftException("Offset should be a positive integer.") self._...
python
def set_offset(self, offset): """ The page number which is in increments of 10. The default page number is 0. :param offset: :return: """ if not isinstance(offset, int) or offset < 0: raise DaftException("Offset should be a positive integer.") self._...
[ "def", "set_offset", "(", "self", ",", "offset", ")", ":", "if", "not", "isinstance", "(", "offset", ",", "int", ")", "or", "offset", "<", "0", ":", "raise", "DaftException", "(", "\"Offset should be a positive integer.\"", ")", "self", ".", "_offset", "=", ...
The page number which is in increments of 10. The default page number is 0. :param offset: :return:
[ "The", "page", "number", "which", "is", "in", "increments", "of", "10", ".", "The", "default", "page", "number", "is", "0", ".", ":", "param", "offset", ":", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L166-L176
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_min_price
def set_min_price(self, min_price): """ The minimum price. :param min_price: :return: """ if not isinstance(min_price, int): raise DaftException("Min price should be an integer.") self._min_price = str(min_price) self._price += str(QueryParam...
python
def set_min_price(self, min_price): """ The minimum price. :param min_price: :return: """ if not isinstance(min_price, int): raise DaftException("Min price should be an integer.") self._min_price = str(min_price) self._price += str(QueryParam...
[ "def", "set_min_price", "(", "self", ",", "min_price", ")", ":", "if", "not", "isinstance", "(", "min_price", ",", "int", ")", ":", "raise", "DaftException", "(", "\"Min price should be an integer.\"", ")", "self", ".", "_min_price", "=", "str", "(", "min_pric...
The minimum price. :param min_price: :return:
[ "The", "minimum", "price", ".", ":", "param", "min_price", ":", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L178-L189
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_max_price
def set_max_price(self, max_price): """ The maximum price. :param max_price: :return: """ if not isinstance(max_price, int): raise DaftException("Max price should be an integer.") self._max_price = str(max_price) self._price += str(QueryParam...
python
def set_max_price(self, max_price): """ The maximum price. :param max_price: :return: """ if not isinstance(max_price, int): raise DaftException("Max price should be an integer.") self._max_price = str(max_price) self._price += str(QueryParam...
[ "def", "set_max_price", "(", "self", ",", "max_price", ")", ":", "if", "not", "isinstance", "(", "max_price", ",", "int", ")", ":", "raise", "DaftException", "(", "\"Max price should be an integer.\"", ")", "self", ".", "_max_price", "=", "str", "(", "max_pric...
The maximum price. :param max_price: :return:
[ "The", "maximum", "price", ".", ":", "param", "max_price", ":", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L191-L202
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_listing_type
def set_listing_type(self, listing_type): """ The listings you'd like to scrape i.e houses, properties, auction, commercial or apartments. Use the SaleType or RentType enum to select the listing type. i.e set_listing_type(SaleType.PROPERTIES) :param listing_type: :return:...
python
def set_listing_type(self, listing_type): """ The listings you'd like to scrape i.e houses, properties, auction, commercial or apartments. Use the SaleType or RentType enum to select the listing type. i.e set_listing_type(SaleType.PROPERTIES) :param listing_type: :return:...
[ "def", "set_listing_type", "(", "self", ",", "listing_type", ")", ":", "if", "not", "isinstance", "(", "listing_type", ",", "SaleType", ")", "and", "not", "isinstance", "(", "listing_type", ",", "RentType", ")", ":", "raise", "DaftException", "(", "\"listing_t...
The listings you'd like to scrape i.e houses, properties, auction, commercial or apartments. Use the SaleType or RentType enum to select the listing type. i.e set_listing_type(SaleType.PROPERTIES) :param listing_type: :return:
[ "The", "listings", "you", "d", "like", "to", "scrape", "i", ".", "e", "houses", "properties", "auction", "commercial", "or", "apartments", ".", "Use", "the", "SaleType", "or", "RentType", "enum", "to", "select", "the", "listing", "type", ".", "i", ".", "...
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L204-L216
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_min_beds
def set_min_beds(self, min_beds): """ The minimum number of beds. :param min_beds: :return: """ if not isinstance(min_beds, int): raise DaftException("Minimum number of beds should be an integer.") self._min_beds = str(min_beds) self._query_p...
python
def set_min_beds(self, min_beds): """ The minimum number of beds. :param min_beds: :return: """ if not isinstance(min_beds, int): raise DaftException("Minimum number of beds should be an integer.") self._min_beds = str(min_beds) self._query_p...
[ "def", "set_min_beds", "(", "self", ",", "min_beds", ")", ":", "if", "not", "isinstance", "(", "min_beds", ",", "int", ")", ":", "raise", "DaftException", "(", "\"Minimum number of beds should be an integer.\"", ")", "self", ".", "_min_beds", "=", "str", "(", ...
The minimum number of beds. :param min_beds: :return:
[ "The", "minimum", "number", "of", "beds", ".", ":", "param", "min_beds", ":", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L226-L237
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_max_beds
def set_max_beds(self, max_beds): """ The maximum number of beds. :param max_beds: :return: """ if not isinstance(max_beds, int): raise DaftException("Maximum number of beds should be an integer.") self._max_beds = str(max_beds) self._query_pa...
python
def set_max_beds(self, max_beds): """ The maximum number of beds. :param max_beds: :return: """ if not isinstance(max_beds, int): raise DaftException("Maximum number of beds should be an integer.") self._max_beds = str(max_beds) self._query_pa...
[ "def", "set_max_beds", "(", "self", ",", "max_beds", ")", ":", "if", "not", "isinstance", "(", "max_beds", ",", "int", ")", ":", "raise", "DaftException", "(", "\"Maximum number of beds should be an integer.\"", ")", "self", ".", "_max_beds", "=", "str", "(", ...
The maximum number of beds. :param max_beds: :return:
[ "The", "maximum", "number", "of", "beds", ".", ":", "param", "max_beds", ":", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L239-L249
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_sort_by
def set_sort_by(self, sort_by): """ Use this method to sort by price, distance, upcoming viewing or date using the SortType object. :param sort_by: :return: """ if not isinstance(sort_by, SortType): raise DaftException("sort_by should be an instance of SortTyp...
python
def set_sort_by(self, sort_by): """ Use this method to sort by price, distance, upcoming viewing or date using the SortType object. :param sort_by: :return: """ if not isinstance(sort_by, SortType): raise DaftException("sort_by should be an instance of SortTyp...
[ "def", "set_sort_by", "(", "self", ",", "sort_by", ")", ":", "if", "not", "isinstance", "(", "sort_by", ",", "SortType", ")", ":", "raise", "DaftException", "(", "\"sort_by should be an instance of SortType.\"", ")", "self", ".", "_sort_by", "=", "str", "(", "...
Use this method to sort by price, distance, upcoming viewing or date using the SortType object. :param sort_by: :return:
[ "Use", "this", "method", "to", "sort", "by", "price", "distance", "upcoming", "viewing", "or", "date", "using", "the", "SortType", "object", ".", ":", "param", "sort_by", ":", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L251-L260
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_sort_order
def set_sort_order(self, sort_order): """ Use the SortOrder object to sort the listings descending or ascending. :param sort_order: :return: """ if not isinstance(sort_order, SortOrder): raise DaftException("sort_order should be an instance of SortOrder.") ...
python
def set_sort_order(self, sort_order): """ Use the SortOrder object to sort the listings descending or ascending. :param sort_order: :return: """ if not isinstance(sort_order, SortOrder): raise DaftException("sort_order should be an instance of SortOrder.") ...
[ "def", "set_sort_order", "(", "self", ",", "sort_order", ")", ":", "if", "not", "isinstance", "(", "sort_order", ",", "SortOrder", ")", ":", "raise", "DaftException", "(", "\"sort_order should be an instance of SortOrder.\"", ")", "self", ".", "_sort_order", "=", ...
Use the SortOrder object to sort the listings descending or ascending. :param sort_order: :return:
[ "Use", "the", "SortOrder", "object", "to", "sort", "the", "listings", "descending", "or", "ascending", ".", ":", "param", "sort_order", ":", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L262-L272
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_commercial_property_type
def set_commercial_property_type(self, commercial_property_type): """ Use the CommercialType object to set the commercial property type. :param commercial_property_type: :return: """ if not isinstance(commercial_property_type, CommercialType): raise DaftExcep...
python
def set_commercial_property_type(self, commercial_property_type): """ Use the CommercialType object to set the commercial property type. :param commercial_property_type: :return: """ if not isinstance(commercial_property_type, CommercialType): raise DaftExcep...
[ "def", "set_commercial_property_type", "(", "self", ",", "commercial_property_type", ")", ":", "if", "not", "isinstance", "(", "commercial_property_type", ",", "CommercialType", ")", ":", "raise", "DaftException", "(", "\"commercial_property_type should be an instance of Comm...
Use the CommercialType object to set the commercial property type. :param commercial_property_type: :return:
[ "Use", "the", "CommercialType", "object", "to", "set", "the", "commercial", "property", "type", ".", ":", "param", "commercial_property_type", ":", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L274-L284
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_commercial_min_size
def set_commercial_min_size(self, commercial_min_size): """ The minimum size in sq ft. :param commercial_min_size: :return: """ if not isinstance(commercial_min_size, int): raise DaftException("commercial_min_size should be an integer.") self._commerc...
python
def set_commercial_min_size(self, commercial_min_size): """ The minimum size in sq ft. :param commercial_min_size: :return: """ if not isinstance(commercial_min_size, int): raise DaftException("commercial_min_size should be an integer.") self._commerc...
[ "def", "set_commercial_min_size", "(", "self", ",", "commercial_min_size", ")", ":", "if", "not", "isinstance", "(", "commercial_min_size", ",", "int", ")", ":", "raise", "DaftException", "(", "\"commercial_min_size should be an integer.\"", ")", "self", ".", "_commer...
The minimum size in sq ft. :param commercial_min_size: :return:
[ "The", "minimum", "size", "in", "sq", "ft", ".", ":", "param", "commercial_min_size", ":", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L286-L296
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_commercial_max_size
def set_commercial_max_size(self, commercial_max_size): """ The maximum size in sq ft. :param commercial_max_size: :return: """ if not isinstance(commercial_max_size, int): raise DaftException("commercial_max_size should be an integer.") self._commerc...
python
def set_commercial_max_size(self, commercial_max_size): """ The maximum size in sq ft. :param commercial_max_size: :return: """ if not isinstance(commercial_max_size, int): raise DaftException("commercial_max_size should be an integer.") self._commerc...
[ "def", "set_commercial_max_size", "(", "self", ",", "commercial_max_size", ")", ":", "if", "not", "isinstance", "(", "commercial_max_size", ",", "int", ")", ":", "raise", "DaftException", "(", "\"commercial_max_size should be an integer.\"", ")", "self", ".", "_commer...
The maximum size in sq ft. :param commercial_max_size: :return:
[ "The", "maximum", "size", "in", "sq", "ft", ".", ":", "param", "commercial_max_size", ":", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L298-L308
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_student_accommodation_type
def set_student_accommodation_type(self, student_accommodation_type): """ Set the student accomodation type. :param student_accommodation_type: StudentAccomodationType """ if not isinstance(student_accommodation_type, StudentAccommodationType): raise DaftException("st...
python
def set_student_accommodation_type(self, student_accommodation_type): """ Set the student accomodation type. :param student_accommodation_type: StudentAccomodationType """ if not isinstance(student_accommodation_type, StudentAccommodationType): raise DaftException("st...
[ "def", "set_student_accommodation_type", "(", "self", ",", "student_accommodation_type", ")", ":", "if", "not", "isinstance", "(", "student_accommodation_type", ",", "StudentAccommodationType", ")", ":", "raise", "DaftException", "(", "\"student_accommodation_type should be a...
Set the student accomodation type. :param student_accommodation_type: StudentAccomodationType
[ "Set", "the", "student", "accomodation", "type", ".", ":", "param", "student_accommodation_type", ":", "StudentAccomodationType" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L318-L326
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_num_occupants
def set_num_occupants(self, num_occupants): """ Set the max number of occupants living in the property for rent. :param num_occupants: int """ self._query_params += str(QueryParam.NUM_OCCUPANTS) + str(num_occupants)
python
def set_num_occupants(self, num_occupants): """ Set the max number of occupants living in the property for rent. :param num_occupants: int """ self._query_params += str(QueryParam.NUM_OCCUPANTS) + str(num_occupants)
[ "def", "set_num_occupants", "(", "self", ",", "num_occupants", ")", ":", "self", ".", "_query_params", "+=", "str", "(", "QueryParam", ".", "NUM_OCCUPANTS", ")", "+", "str", "(", "num_occupants", ")" ]
Set the max number of occupants living in the property for rent. :param num_occupants: int
[ "Set", "the", "max", "number", "of", "occupants", "living", "in", "the", "property", "for", "rent", ".", ":", "param", "num_occupants", ":", "int" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L328-L333
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_public_transport_route
def set_public_transport_route(self, public_transport_route): """ Set the public transport route. :param public_transport_route: TransportRoute """ self._query_params += str(QueryParam.ROUTE_ID) + str(public_transport_route)
python
def set_public_transport_route(self, public_transport_route): """ Set the public transport route. :param public_transport_route: TransportRoute """ self._query_params += str(QueryParam.ROUTE_ID) + str(public_transport_route)
[ "def", "set_public_transport_route", "(", "self", ",", "public_transport_route", ")", ":", "self", ".", "_query_params", "+=", "str", "(", "QueryParam", ".", "ROUTE_ID", ")", "+", "str", "(", "public_transport_route", ")" ]
Set the public transport route. :param public_transport_route: TransportRoute
[ "Set", "the", "public", "transport", "route", ".", ":", "param", "public_transport_route", ":", "TransportRoute" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L342-L347
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.set_property_type
def set_property_type(self, property_types): """ Set the property type for rents. :param property_types: Array of Enum PropertyType """ query_add = '' for property_type in property_types: if not isinstance(property_type, PropertyType): raise Da...
python
def set_property_type(self, property_types): """ Set the property type for rents. :param property_types: Array of Enum PropertyType """ query_add = '' for property_type in property_types: if not isinstance(property_type, PropertyType): raise Da...
[ "def", "set_property_type", "(", "self", ",", "property_types", ")", ":", "query_add", "=", "''", "for", "property_type", "in", "property_types", ":", "if", "not", "isinstance", "(", "property_type", ",", "PropertyType", ")", ":", "raise", "DaftException", "(", ...
Set the property type for rents. :param property_types: Array of Enum PropertyType
[ "Set", "the", "property", "type", "for", "rents", ".", ":", "param", "property_types", ":", "Array", "of", "Enum", "PropertyType" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L357-L368
AnthonyBloomer/daftlistings
daftlistings/daft.py
Daft.search
def search(self): """ The search function returns an array of Listing objects. :return: Listing object """ self.set_url() listings = [] request = Request(debug=self._debug) url = self.get_url() soup = request.get(url) divs = soup.find_all("...
python
def search(self): """ The search function returns an array of Listing objects. :return: Listing object """ self.set_url() listings = [] request = Request(debug=self._debug) url = self.get_url() soup = request.get(url) divs = soup.find_all("...
[ "def", "search", "(", "self", ")", ":", "self", ".", "set_url", "(", ")", "listings", "=", "[", "]", "request", "=", "Request", "(", "debug", "=", "self", ".", "_debug", ")", "url", "=", "self", ".", "get_url", "(", ")", "soup", "=", "request", "...
The search function returns an array of Listing objects. :return: Listing object
[ "The", "search", "function", "returns", "an", "array", "of", "Listing", "objects", ".", ":", "return", ":", "Listing", "object" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/daft.py#L424-L436
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.price_change
def price_change(self): """ This method returns any price change. :return: """ try: if self._data_from_search: return self._data_from_search.find('div', {'class': 'price-changes-sr'}).text else: return self._ad_page_content....
python
def price_change(self): """ This method returns any price change. :return: """ try: if self._data_from_search: return self._data_from_search.find('div', {'class': 'price-changes-sr'}).text else: return self._ad_page_content....
[ "def", "price_change", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_data_from_search", ":", "return", "self", ".", "_data_from_search", ".", "find", "(", "'div'", ",", "{", "'class'", ":", "'price-changes-sr'", "}", ")", ".", "text", "else", "...
This method returns any price change. :return:
[ "This", "method", "returns", "any", "price", "change", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L104-L118
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.upcoming_viewings
def upcoming_viewings(self): """ Returns an array of upcoming viewings for a property. :return: """ upcoming_viewings = [] try: if self._data_from_search: viewings = self._data_from_search.find_all( 'div', {'class': 'smi-onv...
python
def upcoming_viewings(self): """ Returns an array of upcoming viewings for a property. :return: """ upcoming_viewings = [] try: if self._data_from_search: viewings = self._data_from_search.find_all( 'div', {'class': 'smi-onv...
[ "def", "upcoming_viewings", "(", "self", ")", ":", "upcoming_viewings", "=", "[", "]", "try", ":", "if", "self", ".", "_data_from_search", ":", "viewings", "=", "self", ".", "_data_from_search", ".", "find_all", "(", "'div'", ",", "{", "'class'", ":", "'sm...
Returns an array of upcoming viewings for a property. :return:
[ "Returns", "an", "array", "of", "upcoming", "viewings", "for", "a", "property", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L121-L140
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.facilities
def facilities(self): """ This method returns the properties facilities. :return: """ facilities = [] try: list_items = self._ad_page_content.select("#facilities li") except Exception as e: if self._debug: logging.error( ...
python
def facilities(self): """ This method returns the properties facilities. :return: """ facilities = [] try: list_items = self._ad_page_content.select("#facilities li") except Exception as e: if self._debug: logging.error( ...
[ "def", "facilities", "(", "self", ")", ":", "facilities", "=", "[", "]", "try", ":", "list_items", "=", "self", ".", "_ad_page_content", ".", "select", "(", "\"#facilities li\"", ")", "except", "Exception", "as", "e", ":", "if", "self", ".", "_debug", ":...
This method returns the properties facilities. :return:
[ "This", "method", "returns", "the", "properties", "facilities", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L143-L159
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.overviews
def overviews(self): """ This method returns the properties overviews. :return: """ overviews = [] try: list_items = self._ad_page_content.select("#overview li") except Exception as e: if self._debug: logging.error( ...
python
def overviews(self): """ This method returns the properties overviews. :return: """ overviews = [] try: list_items = self._ad_page_content.select("#overview li") except Exception as e: if self._debug: logging.error( ...
[ "def", "overviews", "(", "self", ")", ":", "overviews", "=", "[", "]", "try", ":", "list_items", "=", "self", ".", "_ad_page_content", ".", "select", "(", "\"#overview li\"", ")", "except", "Exception", "as", "e", ":", "if", "self", ".", "_debug", ":", ...
This method returns the properties overviews. :return:
[ "This", "method", "returns", "the", "properties", "overviews", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L162-L178
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.features
def features(self): """ This method returns the properties features. :return: """ features = [] try: list_items = self._ad_page_content.select("#features li") except Exception as e: if self._debug: logging.error( ...
python
def features(self): """ This method returns the properties features. :return: """ features = [] try: list_items = self._ad_page_content.select("#features li") except Exception as e: if self._debug: logging.error( ...
[ "def", "features", "(", "self", ")", ":", "features", "=", "[", "]", "try", ":", "list_items", "=", "self", ".", "_ad_page_content", ".", "select", "(", "\"#features li\"", ")", "except", "Exception", "as", "e", ":", "if", "self", ".", "_debug", ":", "...
This method returns the properties features. :return:
[ "This", "method", "returns", "the", "properties", "features", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L181-L197
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.formalised_address
def formalised_address(self): """ This method returns the formalised address. :return: """ try: if self._data_from_search: t = self._data_from_search.find('a').contents[0] else: t = self._ad_page_content.find( ...
python
def formalised_address(self): """ This method returns the formalised address. :return: """ try: if self._data_from_search: t = self._data_from_search.find('a').contents[0] else: t = self._ad_page_content.find( ...
[ "def", "formalised_address", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_data_from_search", ":", "t", "=", "self", ".", "_data_from_search", ".", "find", "(", "'a'", ")", ".", "contents", "[", "0", "]", "else", ":", "t", "=", "self", ".",...
This method returns the formalised address. :return:
[ "This", "method", "returns", "the", "formalised", "address", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L200-L224
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.address_line_1
def address_line_1(self): """ This method returns the first line of the address. :return: """ formalised_address = self.formalised_address if formalised_address is None: return try: address = formalised_address.split(',') except Exc...
python
def address_line_1(self): """ This method returns the first line of the address. :return: """ formalised_address = self.formalised_address if formalised_address is None: return try: address = formalised_address.split(',') except Exc...
[ "def", "address_line_1", "(", "self", ")", ":", "formalised_address", "=", "self", ".", "formalised_address", "if", "formalised_address", "is", "None", ":", "return", "try", ":", "address", "=", "formalised_address", ".", "split", "(", "','", ")", "except", "E...
This method returns the first line of the address. :return:
[ "This", "method", "returns", "the", "first", "line", "of", "the", "address", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L227-L243
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.images
def images(self): """ This method returns the listing image. :return: """ try: uls = self._ad_page_content.find( "ul", {"class": "smi-gallery-list"}) except Exception as e: if self._debug: logging.error( ...
python
def images(self): """ This method returns the listing image. :return: """ try: uls = self._ad_page_content.find( "ul", {"class": "smi-gallery-list"}) except Exception as e: if self._debug: logging.error( ...
[ "def", "images", "(", "self", ")", ":", "try", ":", "uls", "=", "self", ".", "_ad_page_content", ".", "find", "(", "\"ul\"", ",", "{", "\"class\"", ":", "\"smi-gallery-list\"", "}", ")", "except", "Exception", "as", "e", ":", "if", "self", ".", "_debug...
This method returns the listing image. :return:
[ "This", "method", "returns", "the", "listing", "image", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L266-L286
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.agent
def agent(self): """ This method returns the agent name. :return: """ try: if self._data_from_search: agent = self._data_from_search.find( 'ul', {'class': 'links'}).text return agent.split(':')[1].strip() ...
python
def agent(self): """ This method returns the agent name. :return: """ try: if self._data_from_search: agent = self._data_from_search.find( 'ul', {'class': 'links'}).text return agent.split(':')[1].strip() ...
[ "def", "agent", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_data_from_search", ":", "agent", "=", "self", ".", "_data_from_search", ".", "find", "(", "'ul'", ",", "{", "'class'", ":", "'links'", "}", ")", ".", "text", "return", "agent", "...
This method returns the agent name. :return:
[ "This", "method", "returns", "the", "agent", "name", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L311-L327
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.agent_url
def agent_url(self): """ This method returns the agent's url. :return: """ try: if self._data_from_search: agent = self._data_from_search.find('ul', {'class': 'links'}) links = agent.find_all('a') return links[1]['href']...
python
def agent_url(self): """ This method returns the agent's url. :return: """ try: if self._data_from_search: agent = self._data_from_search.find('ul', {'class': 'links'}) links = agent.find_all('a') return links[1]['href']...
[ "def", "agent_url", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_data_from_search", ":", "agent", "=", "self", ".", "_data_from_search", ".", "find", "(", "'ul'", ",", "{", "'class'", ":", "'links'", "}", ")", "links", "=", "agent", ".", "...
This method returns the agent's url. :return:
[ "This", "method", "returns", "the", "agent", "s", "url", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L330-L346
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.contact_number
def contact_number(self): """ This method returns the contact phone number. :return: """ try: number = self._ad_page_content.find( 'button', {'class': 'phone-number'}) return (base64.b64decode(number.attrs['data-p'])).decode('ascii') ...
python
def contact_number(self): """ This method returns the contact phone number. :return: """ try: number = self._ad_page_content.find( 'button', {'class': 'phone-number'}) return (base64.b64decode(number.attrs['data-p'])).decode('ascii') ...
[ "def", "contact_number", "(", "self", ")", ":", "try", ":", "number", "=", "self", ".", "_ad_page_content", ".", "find", "(", "'button'", ",", "{", "'class'", ":", "'phone-number'", "}", ")", "return", "(", "base64", ".", "b64decode", "(", "number", ".",...
This method returns the contact phone number. :return:
[ "This", "method", "returns", "the", "contact", "phone", "number", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L349-L362
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.daft_link
def daft_link(self): """ This method returns the url of the listing. :return: """ try: if self._data_from_search: link = self._data_from_search.find('a', href=True) return 'http://www.daft.ie' + link['href'] else: ...
python
def daft_link(self): """ This method returns the url of the listing. :return: """ try: if self._data_from_search: link = self._data_from_search.find('a', href=True) return 'http://www.daft.ie' + link['href'] else: ...
[ "def", "daft_link", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_data_from_search", ":", "link", "=", "self", ".", "_data_from_search", ".", "find", "(", "'a'", ",", "href", "=", "True", ")", "return", "'http://www.daft.ie'", "+", "link", "[",...
This method returns the url of the listing. :return:
[ "This", "method", "returns", "the", "url", "of", "the", "listing", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L365-L380
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.shortcode
def shortcode(self): """ This method returns the shortcode url of the listing. :return: """ try: div = self._ad_page_content.find( 'div', {'class': 'description_extras'}) index = [i for i, s in enumerate( div.contents) if 'S...
python
def shortcode(self): """ This method returns the shortcode url of the listing. :return: """ try: div = self._ad_page_content.find( 'div', {'class': 'description_extras'}) index = [i for i, s in enumerate( div.contents) if 'S...
[ "def", "shortcode", "(", "self", ")", ":", "try", ":", "div", "=", "self", ".", "_ad_page_content", ".", "find", "(", "'div'", ",", "{", "'class'", ":", "'description_extras'", "}", ")", "index", "=", "[", "i", "for", "i", ",", "s", "in", "enumerate"...
This method returns the shortcode url of the listing. :return:
[ "This", "method", "returns", "the", "shortcode", "url", "of", "the", "listing", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L383-L398
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.views
def views(self): """ This method returns the "Property Views" from listing. :return: """ try: div = self._ad_page_content.find( 'div', {'class': 'description_extras'}) index = [i for i, s in enumerate( div.contents) if 'Prop...
python
def views(self): """ This method returns the "Property Views" from listing. :return: """ try: div = self._ad_page_content.find( 'div', {'class': 'description_extras'}) index = [i for i, s in enumerate( div.contents) if 'Prop...
[ "def", "views", "(", "self", ")", ":", "try", ":", "div", "=", "self", ".", "_ad_page_content", ".", "find", "(", "'div'", ",", "{", "'class'", ":", "'description_extras'", "}", ")", "index", "=", "[", "i", "for", "i", ",", "s", "in", "enumerate", ...
This method returns the "Property Views" from listing. :return:
[ "This", "method", "returns", "the", "Property", "Views", "from", "listing", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L419-L434
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.dwelling_type
def dwelling_type(self): """ This method returns the dwelling type. :return: """ try: if self._data_from_search: info = self._data_from_search.find( 'ul', {"class": "info"}).text s = info.split('|') r...
python
def dwelling_type(self): """ This method returns the dwelling type. :return: """ try: if self._data_from_search: info = self._data_from_search.find( 'ul', {"class": "info"}).text s = info.split('|') r...
[ "def", "dwelling_type", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_data_from_search", ":", "info", "=", "self", ".", "_data_from_search", ".", "find", "(", "'ul'", ",", "{", "\"class\"", ":", "\"info\"", "}", ")", ".", "text", "s", "=", ...
This method returns the dwelling type. :return:
[ "This", "method", "returns", "the", "dwelling", "type", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L437-L457
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.posted_since
def posted_since(self): """ This method returns the date the listing was entered. :return: """ try: if self._data_from_search: info = self._data_from_search.find( 'div', {"class": "date_entered"}).text s = info.split...
python
def posted_since(self): """ This method returns the date the listing was entered. :return: """ try: if self._data_from_search: info = self._data_from_search.find( 'div', {"class": "date_entered"}).text s = info.split...
[ "def", "posted_since", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_data_from_search", ":", "info", "=", "self", ".", "_data_from_search", ".", "find", "(", "'div'", ",", "{", "\"class\"", ":", "\"date_entered\"", "}", ")", ".", "text", "s", ...
This method returns the date the listing was entered. :return:
[ "This", "method", "returns", "the", "date", "the", "listing", "was", "entered", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L460-L481
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.bedrooms
def bedrooms(self): """ This method gets the number of bedrooms. :return: """ try: if self._data_from_search: info = self._data_from_search.find( 'ul', {"class": "info"}).text s = info.split('|') nb =...
python
def bedrooms(self): """ This method gets the number of bedrooms. :return: """ try: if self._data_from_search: info = self._data_from_search.find( 'ul', {"class": "info"}).text s = info.split('|') nb =...
[ "def", "bedrooms", "(", "self", ")", ":", "try", ":", "if", "self", ".", "_data_from_search", ":", "info", "=", "self", ".", "_data_from_search", ".", "find", "(", "'ul'", ",", "{", "\"class\"", ":", "\"info\"", "}", ")", ".", "text", "s", "=", "info...
This method gets the number of bedrooms. :return:
[ "This", "method", "gets", "the", "number", "of", "bedrooms", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L484-L509
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.city_center_distance
def city_center_distance(self): """ This method gets the distance to city center, in km. :return: """ try: infos = self._ad_page_content.find_all( 'div', {"class": "map_info_box"}) for info in infos: if 'Distance to City Cen...
python
def city_center_distance(self): """ This method gets the distance to city center, in km. :return: """ try: infos = self._ad_page_content.find_all( 'div', {"class": "map_info_box"}) for info in infos: if 'Distance to City Cen...
[ "def", "city_center_distance", "(", "self", ")", ":", "try", ":", "infos", "=", "self", ".", "_ad_page_content", ".", "find_all", "(", "'div'", ",", "{", "\"class\"", ":", "\"map_info_box\"", "}", ")", "for", "info", "in", "infos", ":", "if", "'Distance to...
This method gets the distance to city center, in km. :return:
[ "This", "method", "gets", "the", "distance", "to", "city", "center", "in", "km", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L541-L559
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.transport_routes
def transport_routes(self): """ This method gets a dict of routes listed in Daft. :return: """ routes = {} try: big_div = self._ad_page_content.find( 'div', {"class": "half_area_box_right"}) uls = big_div.find("ul") if u...
python
def transport_routes(self): """ This method gets a dict of routes listed in Daft. :return: """ routes = {} try: big_div = self._ad_page_content.find( 'div', {"class": "half_area_box_right"}) uls = big_div.find("ul") if u...
[ "def", "transport_routes", "(", "self", ")", ":", "routes", "=", "{", "}", "try", ":", "big_div", "=", "self", ".", "_ad_page_content", ".", "find", "(", "'div'", ",", "{", "\"class\"", ":", "\"half_area_box_right\"", "}", ")", "uls", "=", "big_div", "."...
This method gets a dict of routes listed in Daft. :return:
[ "This", "method", "gets", "a", "dict", "of", "routes", "listed", "in", "Daft", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L562-L582
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.longitude
def longitude(self): """ This method gets a dict of routes listed in Daft. :return: """ try: scripts = self._ad_page_content.find_all('script') for script in scripts: if 'longitude' in script.text: find_list = re.findall...
python
def longitude(self): """ This method gets a dict of routes listed in Daft. :return: """ try: scripts = self._ad_page_content.find_all('script') for script in scripts: if 'longitude' in script.text: find_list = re.findall...
[ "def", "longitude", "(", "self", ")", ":", "try", ":", "scripts", "=", "self", ".", "_ad_page_content", ".", "find_all", "(", "'script'", ")", "for", "script", "in", "scripts", ":", "if", "'longitude'", "in", "script", ".", "text", ":", "find_list", "=",...
This method gets a dict of routes listed in Daft. :return:
[ "This", "method", "gets", "a", "dict", "of", "routes", "listed", "in", "Daft", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L606-L624
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.ber_code
def ber_code(self): """ This method gets ber code listed in Daft. :return: """ try: alt_text = self._ad_page_content.find( 'span', {'class': 'ber-hover'} ).find('img')['alt'] if ('exempt' in alt_text): return 'e...
python
def ber_code(self): """ This method gets ber code listed in Daft. :return: """ try: alt_text = self._ad_page_content.find( 'span', {'class': 'ber-hover'} ).find('img')['alt'] if ('exempt' in alt_text): return 'e...
[ "def", "ber_code", "(", "self", ")", ":", "try", ":", "alt_text", "=", "self", ".", "_ad_page_content", ".", "find", "(", "'span'", ",", "{", "'class'", ":", "'ber-hover'", "}", ")", ".", "find", "(", "'img'", ")", "[", "'alt'", "]", "if", "(", "'e...
This method gets ber code listed in Daft. :return:
[ "This", "method", "gets", "ber", "code", "listed", "in", "Daft", ".", ":", "return", ":" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L627-L649
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.contact_advertiser
def contact_advertiser(self, name, email, contact_number, message): """ This method allows you to contact the advertiser of a listing. :param name: Your name :param email: Your email address. :param contact_number: Your contact number. :param message: Your message. ...
python
def contact_advertiser(self, name, email, contact_number, message): """ This method allows you to contact the advertiser of a listing. :param name: Your name :param email: Your email address. :param contact_number: Your contact number. :param message: Your message. ...
[ "def", "contact_advertiser", "(", "self", ",", "name", ",", "email", ",", "contact_number", ",", "message", ")", ":", "req", "=", "Request", "(", "debug", "=", "self", ".", "_debug", ")", "ad_search_type", "=", "self", ".", "search_type", "agent_id", "=", ...
This method allows you to contact the advertiser of a listing. :param name: Your name :param email: Your email address. :param contact_number: Your contact number. :param message: Your message. :return:
[ "This", "method", "allows", "you", "to", "contact", "the", "advertiser", "of", "a", "listing", ".", ":", "param", "name", ":", "Your", "name", ":", "param", "email", ":", "Your", "email", "address", ".", ":", "param", "contact_number", ":", "Your", "cont...
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L671-L704
AnthonyBloomer/daftlistings
daftlistings/listing.py
Listing.as_dict
def as_dict(self): """ Return a Listing object as Dictionary :return: dict """ return { 'search_type': self.search_type, 'agent_id': self.agent_id, 'id': self.id, 'price': self.price, 'price_change': self.price_change, ...
python
def as_dict(self): """ Return a Listing object as Dictionary :return: dict """ return { 'search_type': self.search_type, 'agent_id': self.agent_id, 'id': self.id, 'price': self.price, 'price_change': self.price_change, ...
[ "def", "as_dict", "(", "self", ")", ":", "return", "{", "'search_type'", ":", "self", ".", "search_type", ",", "'agent_id'", ":", "self", ".", "agent_id", ",", "'id'", ":", "self", ".", "id", ",", "'price'", ":", "self", ".", "price", ",", "'price_chan...
Return a Listing object as Dictionary :return: dict
[ "Return", "a", "Listing", "object", "as", "Dictionary", ":", "return", ":", "dict" ]
train
https://github.com/AnthonyBloomer/daftlistings/blob/f6c1b52425bc740f443b5efe6632a4bf18ee997f/daftlistings/listing.py#L706-L743
fralau/mkdocs_macros_plugin
macros/plugin.py
MacrosPlugin.on_config
def on_config(self, config): "Fetch the variables and functions" #print("Here is the config:", config) # fetch variables from YAML file: self._variables = config.get(YAML_SUBSET) # add variables and functions from the module: module_reader.load_variables(self._variables...
python
def on_config(self, config): "Fetch the variables and functions" #print("Here is the config:", config) # fetch variables from YAML file: self._variables = config.get(YAML_SUBSET) # add variables and functions from the module: module_reader.load_variables(self._variables...
[ "def", "on_config", "(", "self", ",", "config", ")", ":", "#print(\"Here is the config:\", config)", "# fetch variables from YAML file:", "self", ".", "_variables", "=", "config", ".", "get", "(", "YAML_SUBSET", ")", "# add variables and functions from the module:", "module...
Fetch the variables and functions
[ "Fetch", "the", "variables", "and", "functions" ]
train
https://github.com/fralau/mkdocs_macros_plugin/blob/8a02189395adae3acd2d18d9edcf0790ff7b4904/macros/plugin.py#L41-L51
fralau/mkdocs_macros_plugin
macros/plugin.py
MacrosPlugin.on_page_markdown
def on_page_markdown(self, markdown, page, config, site_navigation=None, **kwargs): "Provide a hook for defining functions from an external module" # the site_navigation argument has been made optional # (deleted in post 1.0 mkdocs, but maintained here # for ba...
python
def on_page_markdown(self, markdown, page, config, site_navigation=None, **kwargs): "Provide a hook for defining functions from an external module" # the site_navigation argument has been made optional # (deleted in post 1.0 mkdocs, but maintained here # for ba...
[ "def", "on_page_markdown", "(", "self", ",", "markdown", ",", "page", ",", "config", ",", "site_navigation", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# the site_navigation argument has been made optional", "# (deleted in post 1.0 mkdocs, but maintained here", "# f...
Provide a hook for defining functions from an external module
[ "Provide", "a", "hook", "for", "defining", "functions", "from", "an", "external", "module" ]
train
https://github.com/fralau/mkdocs_macros_plugin/blob/8a02189395adae3acd2d18d9edcf0790ff7b4904/macros/plugin.py#L54-L71
fralau/mkdocs_macros_plugin
macros/module_reader.py
load_variables
def load_variables(variables, config): """ Add the template functions, via the python module located in the same directory as the Yaml config file. The python module must contain the following hook: declare_variables(variables, macro): variables['a'] = 5 @macro def bar(x...
python
def load_variables(variables, config): """ Add the template functions, via the python module located in the same directory as the Yaml config file. The python module must contain the following hook: declare_variables(variables, macro): variables['a'] = 5 @macro def bar(x...
[ "def", "load_variables", "(", "variables", ",", "config", ")", ":", "def", "macro", "(", "v", ",", "name", "=", "''", ")", ":", "\"\"\"\n Registers a variable as a macro in the template,\n i.e. in the variables dictionary:\n\n macro(myfunc)\n\n Opt...
Add the template functions, via the python module located in the same directory as the Yaml config file. The python module must contain the following hook: declare_variables(variables, macro): variables['a'] = 5 @macro def bar(x): .... @macro def baz...
[ "Add", "the", "template", "functions", "via", "the", "python", "module", "located", "in", "the", "same", "directory", "as", "the", "Yaml", "config", "file", "." ]
train
https://github.com/fralau/mkdocs_macros_plugin/blob/8a02189395adae3acd2d18d9edcf0790ff7b4904/macros/module_reader.py#L18-L84
mayeut/pybase64
pybase64/_fallback.py
b64decode
def b64decode(s, altchars=None, validate=False): """Decode bytes encoded with the standard Base64 alphabet. Argument ``s`` is a :term:`bytes-like object` or ASCII string to decode. Optional ``altchars`` must be a :term:`bytes-like object` or ASCII string of length 2 which specifies the alternative...
python
def b64decode(s, altchars=None, validate=False): """Decode bytes encoded with the standard Base64 alphabet. Argument ``s`` is a :term:`bytes-like object` or ASCII string to decode. Optional ``altchars`` must be a :term:`bytes-like object` or ASCII string of length 2 which specifies the alternative...
[ "def", "b64decode", "(", "s", ",", "altchars", "=", "None", ",", "validate", "=", "False", ")", ":", "if", "version_info", "<", "(", "3", ",", "0", ")", "or", "validate", ":", "if", "validate", "and", "len", "(", "s", ")", "%", "4", "!=", "0", ...
Decode bytes encoded with the standard Base64 alphabet. Argument ``s`` is a :term:`bytes-like object` or ASCII string to decode. Optional ``altchars`` must be a :term:`bytes-like object` or ASCII string of length 2 which specifies the alternative alphabet used instead of the '+' and '/' characters...
[ "Decode", "bytes", "encoded", "with", "the", "standard", "Base64", "alphabet", "." ]
train
https://github.com/mayeut/pybase64/blob/861c48675fd6e37c129e1d7a1233074f8d54449e/pybase64/_fallback.py#L40-L86
mayeut/pybase64
pybase64/_fallback.py
b64encode
def b64encode(s, altchars=None): """Encode bytes using the standard Base64 alphabet. Argument ``s`` is a :term:`bytes-like object` to encode. Optional ``altchars`` must be a byte string of length 2 which specifies an alternative alphabet for the '+' and '/' characters. This allows an application ...
python
def b64encode(s, altchars=None): """Encode bytes using the standard Base64 alphabet. Argument ``s`` is a :term:`bytes-like object` to encode. Optional ``altchars`` must be a byte string of length 2 which specifies an alternative alphabet for the '+' and '/' characters. This allows an application ...
[ "def", "b64encode", "(", "s", ",", "altchars", "=", "None", ")", ":", "if", "altchars", "is", "not", "None", ":", "altchars", "=", "_get_bytes", "(", "altchars", ")", "assert", "len", "(", "altchars", ")", "==", "2", ",", "repr", "(", "altchars", ")"...
Encode bytes using the standard Base64 alphabet. Argument ``s`` is a :term:`bytes-like object` to encode. Optional ``altchars`` must be a byte string of length 2 which specifies an alternative alphabet for the '+' and '/' characters. This allows an application to e.g. generate url or filesystem safe ...
[ "Encode", "bytes", "using", "the", "standard", "Base64", "alphabet", "." ]
train
https://github.com/mayeut/pybase64/blob/861c48675fd6e37c129e1d7a1233074f8d54449e/pybase64/_fallback.py#L89-L107
mayeut/pybase64
setup.py
CleanExtensionCommand.run
def run(self): """Run command.""" for ext in ['*.so', '*.pyd']: for file in glob.glob('./pybase64/' + ext): log.info("removing '%s'", file) if self.dry_run: continue os.remove(file)
python
def run(self): """Run command.""" for ext in ['*.so', '*.pyd']: for file in glob.glob('./pybase64/' + ext): log.info("removing '%s'", file) if self.dry_run: continue os.remove(file)
[ "def", "run", "(", "self", ")", ":", "for", "ext", "in", "[", "'*.so'", ",", "'*.pyd'", "]", ":", "for", "file", "in", "glob", ".", "glob", "(", "'./pybase64/'", "+", "ext", ")", ":", "log", ".", "info", "(", "\"removing '%s'\"", ",", "file", ")", ...
Run command.
[ "Run", "command", "." ]
train
https://github.com/mayeut/pybase64/blob/861c48675fd6e37c129e1d7a1233074f8d54449e/setup.py#L204-L211
kalbhor/MusicTools
musictools/musictools.py
improve_name
def improve_name(song_name): """ Improves file name by removing words such as HD, Official,etc eg : Hey Jude (Official HD) lyrics -> Hey Jude This helps in better searching of metadata since a spotify search of 'Hey Jude (Official HD) lyrics' fetches 0 results """ try: song_name = o...
python
def improve_name(song_name): """ Improves file name by removing words such as HD, Official,etc eg : Hey Jude (Official HD) lyrics -> Hey Jude This helps in better searching of metadata since a spotify search of 'Hey Jude (Official HD) lyrics' fetches 0 results """ try: song_name = o...
[ "def", "improve_name", "(", "song_name", ")", ":", "try", ":", "song_name", "=", "os", ".", "path", ".", "splitext", "(", "song_name", ")", "[", "0", "]", "except", "IndexError", ":", "pass", "song_name", "=", "song_name", ".", "partition", "(", "'ft'", ...
Improves file name by removing words such as HD, Official,etc eg : Hey Jude (Official HD) lyrics -> Hey Jude This helps in better searching of metadata since a spotify search of 'Hey Jude (Official HD) lyrics' fetches 0 results
[ "Improves", "file", "name", "by", "removing", "words", "such", "as", "HD", "Official", "etc", "eg", ":", "Hey", "Jude", "(", "Official", "HD", ")", "lyrics", "-", ">", "Hey", "Jude", "This", "helps", "in", "better", "searching", "of", "metadata", "since"...
train
https://github.com/kalbhor/MusicTools/blob/324159448553033173bb050458c6a56e3cfa2738/musictools/musictools.py#L18-L44
kalbhor/MusicTools
musictools/musictools.py
get_song_urls
def get_song_urls(song_input): """ Gather all urls, titles for a search query from youtube """ YOUTUBECLASS = 'spf-prefetch' html = requests.get("https://www.youtube.com/results", params={'search_query': song_input}) soup = BeautifulSoup(html.text, 'html.parser') ...
python
def get_song_urls(song_input): """ Gather all urls, titles for a search query from youtube """ YOUTUBECLASS = 'spf-prefetch' html = requests.get("https://www.youtube.com/results", params={'search_query': song_input}) soup = BeautifulSoup(html.text, 'html.parser') ...
[ "def", "get_song_urls", "(", "song_input", ")", ":", "YOUTUBECLASS", "=", "'spf-prefetch'", "html", "=", "requests", ".", "get", "(", "\"https://www.youtube.com/results\"", ",", "params", "=", "{", "'search_query'", ":", "song_input", "}", ")", "soup", "=", "Bea...
Gather all urls, titles for a search query from youtube
[ "Gather", "all", "urls", "titles", "for", "a", "search", "query", "from", "youtube" ]
train
https://github.com/kalbhor/MusicTools/blob/324159448553033173bb050458c6a56e3cfa2738/musictools/musictools.py#L46-L69
kalbhor/MusicTools
musictools/musictools.py
download_song
def download_song(song_url, song_title): """ Download a song using youtube url and song title """ outtmpl = song_title + '.%(ext)s' ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': outtmpl, 'postprocessors': [ {'key': 'FFmpegExtractAudio','preferredcodec': 'mp...
python
def download_song(song_url, song_title): """ Download a song using youtube url and song title """ outtmpl = song_title + '.%(ext)s' ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': outtmpl, 'postprocessors': [ {'key': 'FFmpegExtractAudio','preferredcodec': 'mp...
[ "def", "download_song", "(", "song_url", ",", "song_title", ")", ":", "outtmpl", "=", "song_title", "+", "'.%(ext)s'", "ydl_opts", "=", "{", "'format'", ":", "'bestaudio/best'", ",", "'outtmpl'", ":", "outtmpl", ",", "'postprocessors'", ":", "[", "{", "'key'",...
Download a song using youtube url and song title
[ "Download", "a", "song", "using", "youtube", "url", "and", "song", "title" ]
train
https://github.com/kalbhor/MusicTools/blob/324159448553033173bb050458c6a56e3cfa2738/musictools/musictools.py#L72-L90
kalbhor/MusicTools
musictools/musictools.py
get_metadata
def get_metadata(file_name, client_id, client_secret): """ Tries finding metadata through Spotify """ song_name = improve_name(file_name) # Remove useless words from title client_credentials_manager = SpotifyClientCredentials(client_id, client_secret) spotify = spotipy.Spotify(client_credenti...
python
def get_metadata(file_name, client_id, client_secret): """ Tries finding metadata through Spotify """ song_name = improve_name(file_name) # Remove useless words from title client_credentials_manager = SpotifyClientCredentials(client_id, client_secret) spotify = spotipy.Spotify(client_credenti...
[ "def", "get_metadata", "(", "file_name", ",", "client_id", ",", "client_secret", ")", ":", "song_name", "=", "improve_name", "(", "file_name", ")", "# Remove useless words from title", "client_credentials_manager", "=", "SpotifyClientCredentials", "(", "client_id", ",", ...
Tries finding metadata through Spotify
[ "Tries", "finding", "metadata", "through", "Spotify" ]
train
https://github.com/kalbhor/MusicTools/blob/324159448553033173bb050458c6a56e3cfa2738/musictools/musictools.py#L93-L110
kalbhor/MusicTools
musictools/musictools.py
add_album_art
def add_album_art(file_name, album_art): """ Add album_art in .mp3's tags """ img = requests.get(album_art, stream=True) # Gets album art from url img = img.raw audio = EasyMP3(file_name, ID3=ID3) try: audio.add_tags() except _util.error: pass audio.tags.add( ...
python
def add_album_art(file_name, album_art): """ Add album_art in .mp3's tags """ img = requests.get(album_art, stream=True) # Gets album art from url img = img.raw audio = EasyMP3(file_name, ID3=ID3) try: audio.add_tags() except _util.error: pass audio.tags.add( ...
[ "def", "add_album_art", "(", "file_name", ",", "album_art", ")", ":", "img", "=", "requests", ".", "get", "(", "album_art", ",", "stream", "=", "True", ")", "# Gets album art from url", "img", "=", "img", ".", "raw", "audio", "=", "EasyMP3", "(", "file_nam...
Add album_art in .mp3's tags
[ "Add", "album_art", "in", ".", "mp3", "s", "tags" ]
train
https://github.com/kalbhor/MusicTools/blob/324159448553033173bb050458c6a56e3cfa2738/musictools/musictools.py#L113-L139
kalbhor/MusicTools
musictools/musictools.py
add_metadata
def add_metadata(file_name, title, artist, album): """ As the method name suggests """ tags = EasyMP3(file_name) if title: tags["title"] = title if artist: tags["artist"] = artist if album: tags["album"] = album tags.save() return file_name
python
def add_metadata(file_name, title, artist, album): """ As the method name suggests """ tags = EasyMP3(file_name) if title: tags["title"] = title if artist: tags["artist"] = artist if album: tags["album"] = album tags.save() return file_name
[ "def", "add_metadata", "(", "file_name", ",", "title", ",", "artist", ",", "album", ")", ":", "tags", "=", "EasyMP3", "(", "file_name", ")", "if", "title", ":", "tags", "[", "\"title\"", "]", "=", "title", "if", "artist", ":", "tags", "[", "\"artist\""...
As the method name suggests
[ "As", "the", "method", "name", "suggests" ]
train
https://github.com/kalbhor/MusicTools/blob/324159448553033173bb050458c6a56e3cfa2738/musictools/musictools.py#L142-L156
kalbhor/MusicTools
musictools/musictools.py
revert_metadata
def revert_metadata(files): """ Removes all tags from a mp3 file """ for file_path in files: tags = EasyMP3(file_path) tags.delete() tags.save()
python
def revert_metadata(files): """ Removes all tags from a mp3 file """ for file_path in files: tags = EasyMP3(file_path) tags.delete() tags.save()
[ "def", "revert_metadata", "(", "files", ")", ":", "for", "file_path", "in", "files", ":", "tags", "=", "EasyMP3", "(", "file_path", ")", "tags", ".", "delete", "(", ")", "tags", ".", "save", "(", ")" ]
Removes all tags from a mp3 file
[ "Removes", "all", "tags", "from", "a", "mp3", "file" ]
train
https://github.com/kalbhor/MusicTools/blob/324159448553033173bb050458c6a56e3cfa2738/musictools/musictools.py#L166-L173
Tivix/django-braintree
django_braintree/models.py
UserVaultManager.get_user_vault_instance_or_none
def get_user_vault_instance_or_none(self, user): """Returns a vault_id string or None""" qset = self.filter(user=user) if not qset: return None if qset.count() > 1: raise Exception('This app does not currently support multiple vault ids') ...
python
def get_user_vault_instance_or_none(self, user): """Returns a vault_id string or None""" qset = self.filter(user=user) if not qset: return None if qset.count() > 1: raise Exception('This app does not currently support multiple vault ids') ...
[ "def", "get_user_vault_instance_or_none", "(", "self", ",", "user", ")", ":", "qset", "=", "self", ".", "filter", "(", "user", "=", "user", ")", "if", "not", "qset", ":", "return", "None", "if", "qset", ".", "count", "(", ")", ">", "1", ":", "raise",...
Returns a vault_id string or None
[ "Returns", "a", "vault_id", "string", "or", "None" ]
train
https://github.com/Tivix/django-braintree/blob/7beb2c8392c2a454c36b353818f3e1db20511ef9/django_braintree/models.py#L11-L20
Tivix/django-braintree
django_braintree/models.py
UserVaultManager.charge
def charge(self, user, vault_id=None): """If vault_id is not passed this will assume that there is only one instane of user and vault_id in the db.""" assert self.is_in_vault(user) if vault_id: user_vault = self.get(user=user, vault_id=vault_id) else: user_vault =...
python
def charge(self, user, vault_id=None): """If vault_id is not passed this will assume that there is only one instane of user and vault_id in the db.""" assert self.is_in_vault(user) if vault_id: user_vault = self.get(user=user, vault_id=vault_id) else: user_vault =...
[ "def", "charge", "(", "self", ",", "user", ",", "vault_id", "=", "None", ")", ":", "assert", "self", ".", "is_in_vault", "(", "user", ")", "if", "vault_id", ":", "user_vault", "=", "self", ".", "get", "(", "user", "=", "user", ",", "vault_id", "=", ...
If vault_id is not passed this will assume that there is only one instane of user and vault_id in the db.
[ "If", "vault_id", "is", "not", "passed", "this", "will", "assume", "that", "there", "is", "only", "one", "instane", "of", "user", "and", "vault_id", "in", "the", "db", "." ]
train
https://github.com/Tivix/django-braintree/blob/7beb2c8392c2a454c36b353818f3e1db20511ef9/django_braintree/models.py#L25-L31
Tivix/django-braintree
django_braintree/models.py
UserVault.charge
def charge(self, amount): """ Charges the users credit card, with he passed $amount, if they are in the vault. Returns the payment_log instance or None (if charge fails etc.) """ try: result = Transaction.sale( { 'amount': amount.qu...
python
def charge(self, amount): """ Charges the users credit card, with he passed $amount, if they are in the vault. Returns the payment_log instance or None (if charge fails etc.) """ try: result = Transaction.sale( { 'amount': amount.qu...
[ "def", "charge", "(", "self", ",", "amount", ")", ":", "try", ":", "result", "=", "Transaction", ".", "sale", "(", "{", "'amount'", ":", "amount", ".", "quantize", "(", "Decimal", "(", "'.01'", ")", ")", ",", "'customer_id'", ":", "self", ".", "vault...
Charges the users credit card, with he passed $amount, if they are in the vault. Returns the payment_log instance or None (if charge fails etc.)
[ "Charges", "the", "users", "credit", "card", "with", "he", "passed", "$amount", "if", "they", "are", "in", "the", "vault", ".", "Returns", "the", "payment_log", "instance", "or", "None", "(", "if", "charge", "fails", "etc", ".", ")" ]
train
https://github.com/Tivix/django-braintree/blob/7beb2c8392c2a454c36b353818f3e1db20511ef9/django_braintree/models.py#L43-L67
Tivix/django-braintree
django_braintree/forms.py
UserCCDetailsForm.save
def save(self, prepend_vault_id=''): """ Adds or updates a users CC to the vault. @prepend_vault_id: any string to prepend all vault id's with in case the same braintree account is used by multiple projects/apps. """ assert self.is_valid() cc_det...
python
def save(self, prepend_vault_id=''): """ Adds or updates a users CC to the vault. @prepend_vault_id: any string to prepend all vault id's with in case the same braintree account is used by multiple projects/apps. """ assert self.is_valid() cc_det...
[ "def", "save", "(", "self", ",", "prepend_vault_id", "=", "''", ")", ":", "assert", "self", ".", "is_valid", "(", ")", "cc_details_map", "=", "{", "# cc details", "'number'", ":", "self", ".", "cleaned_data", "[", "'cc_number'", "]", ",", "'cardholder_name'"...
Adds or updates a users CC to the vault. @prepend_vault_id: any string to prepend all vault id's with in case the same braintree account is used by multiple projects/apps.
[ "Adds", "or", "updates", "a", "users", "CC", "to", "the", "vault", "." ]
train
https://github.com/Tivix/django-braintree/blob/7beb2c8392c2a454c36b353818f3e1db20511ef9/django_braintree/forms.py#L93-L133
Tivix/django-braintree
django_braintree/views.py
payments_billing
def payments_billing(request, template='django_braintree/payments_billing.html'): """ Renders both the past payments that have occurred on the users credit card, but also their CC information on file (if any) """ d = {} if request.method == 'POST': # Credit Card is being changed/upd...
python
def payments_billing(request, template='django_braintree/payments_billing.html'): """ Renders both the past payments that have occurred on the users credit card, but also their CC information on file (if any) """ d = {} if request.method == 'POST': # Credit Card is being changed/upd...
[ "def", "payments_billing", "(", "request", ",", "template", "=", "'django_braintree/payments_billing.html'", ")", ":", "d", "=", "{", "}", "if", "request", ".", "method", "==", "'POST'", ":", "# Credit Card is being changed/updated by the user", "form", "=", "UserCCDe...
Renders both the past payments that have occurred on the users credit card, but also their CC information on file (if any)
[ "Renders", "both", "the", "past", "payments", "that", "have", "occurred", "on", "the", "users", "credit", "card", "but", "also", "their", "CC", "information", "on", "file", "(", "if", "any", ")" ]
train
https://github.com/Tivix/django-braintree/blob/7beb2c8392c2a454c36b353818f3e1db20511ef9/django_braintree/views.py#L20-L48
dropbox/pygerduty
pygerduty/v2.py
Incident.snooze
def snooze(self, requester, duration): """Snooze incident. :param requester: The email address of the individual requesting snooze. """ path = '{0}/{1}/{2}'.format(self.collection.name, self.id, 'snooze') data = {"duration": duration} extra_headers = {"From": requester} ...
python
def snooze(self, requester, duration): """Snooze incident. :param requester: The email address of the individual requesting snooze. """ path = '{0}/{1}/{2}'.format(self.collection.name, self.id, 'snooze') data = {"duration": duration} extra_headers = {"From": requester} ...
[ "def", "snooze", "(", "self", ",", "requester", ",", "duration", ")", ":", "path", "=", "'{0}/{1}/{2}'", ".", "format", "(", "self", ".", "collection", ".", "name", ",", "self", ".", "id", ",", "'snooze'", ")", "data", "=", "{", "\"duration\"", ":", ...
Snooze incident. :param requester: The email address of the individual requesting snooze.
[ "Snooze", "incident", ".", ":", "param", "requester", ":", "The", "email", "address", "of", "the", "individual", "requesting", "snooze", "." ]
train
https://github.com/dropbox/pygerduty/blob/11b28bfb66306aa7fc2b95ab9df65eb97ea831cf/pygerduty/v2.py#L465-L472
dropbox/pygerduty
pygerduty/v2.py
Incident.reassign
def reassign(self, user_ids, requester): """Reassign this incident to a user or list of users :param user_ids: A non-empty list of user ids :param requester: The email address of individual requesting reassign """ path = '{0}'.format(self.collection.name) assignments = [...
python
def reassign(self, user_ids, requester): """Reassign this incident to a user or list of users :param user_ids: A non-empty list of user ids :param requester: The email address of individual requesting reassign """ path = '{0}'.format(self.collection.name) assignments = [...
[ "def", "reassign", "(", "self", ",", "user_ids", ",", "requester", ")", ":", "path", "=", "'{0}'", ".", "format", "(", "self", ".", "collection", ".", "name", ")", "assignments", "=", "[", "]", "if", "not", "user_ids", ":", "raise", "Error", "(", "'M...
Reassign this incident to a user or list of users :param user_ids: A non-empty list of user ids :param requester: The email address of individual requesting reassign
[ "Reassign", "this", "incident", "to", "a", "user", "or", "list", "of", "users" ]
train
https://github.com/dropbox/pygerduty/blob/11b28bfb66306aa7fc2b95ab9df65eb97ea831cf/pygerduty/v2.py#L478-L506
dropbox/pygerduty
pygerduty/events.py
Events.resolve_incident
def resolve_incident(self, incident_key, description=None, details=None): """ Causes the referenced incident to enter resolved state. Send a resolve event when the problem that caused the initial trigger has been fixed. """ return self.create_event(descr...
python
def resolve_incident(self, incident_key, description=None, details=None): """ Causes the referenced incident to enter resolved state. Send a resolve event when the problem that caused the initial trigger has been fixed. """ return self.create_event(descr...
[ "def", "resolve_incident", "(", "self", ",", "incident_key", ",", "description", "=", "None", ",", "details", "=", "None", ")", ":", "return", "self", ".", "create_event", "(", "description", ",", "\"resolve\"", ",", "details", ",", "incident_key", ")" ]
Causes the referenced incident to enter resolved state. Send a resolve event when the problem that caused the initial trigger has been fixed.
[ "Causes", "the", "referenced", "incident", "to", "enter", "resolved", "state", ".", "Send", "a", "resolve", "event", "when", "the", "problem", "that", "caused", "the", "initial", "trigger", "has", "been", "fixed", "." ]
train
https://github.com/dropbox/pygerduty/blob/11b28bfb66306aa7fc2b95ab9df65eb97ea831cf/pygerduty/events.py#L57-L65
dropbox/pygerduty
pygerduty/common.py
clean_response
def clean_response(response): '''Recurse through dictionary and replace any keys "self" with "self_"''' if type(response) is list: for elem in response: clean_response(elem) elif type(response) is dict: for key, val in response.items(): if key == 'self': ...
python
def clean_response(response): '''Recurse through dictionary and replace any keys "self" with "self_"''' if type(response) is list: for elem in response: clean_response(elem) elif type(response) is dict: for key, val in response.items(): if key == 'self': ...
[ "def", "clean_response", "(", "response", ")", ":", "if", "type", "(", "response", ")", "is", "list", ":", "for", "elem", "in", "response", ":", "clean_response", "(", "elem", ")", "elif", "type", "(", "response", ")", "is", "dict", ":", "for", "key", ...
Recurse through dictionary and replace any keys "self" with "self_"
[ "Recurse", "through", "dictionary", "and", "replace", "any", "keys", "self", "with", "self_" ]
train
https://github.com/dropbox/pygerduty/blob/11b28bfb66306aa7fc2b95ab9df65eb97ea831cf/pygerduty/common.py#L55-L69
dropbox/pygerduty
pygerduty/common.py
_lower
def _lower(string): """Custom lower string function. Examples: FooBar -> foo_bar """ if not string: return "" new_string = [string[0].lower()] for char in string[1:]: if char.isupper(): new_string.append("_") new_string.append(char.lower()) retur...
python
def _lower(string): """Custom lower string function. Examples: FooBar -> foo_bar """ if not string: return "" new_string = [string[0].lower()] for char in string[1:]: if char.isupper(): new_string.append("_") new_string.append(char.lower()) retur...
[ "def", "_lower", "(", "string", ")", ":", "if", "not", "string", ":", "return", "\"\"", "new_string", "=", "[", "string", "[", "0", "]", ".", "lower", "(", ")", "]", "for", "char", "in", "string", "[", "1", ":", "]", ":", "if", "char", ".", "is...
Custom lower string function. Examples: FooBar -> foo_bar
[ "Custom", "lower", "string", "function", ".", "Examples", ":", "FooBar", "-", ">", "foo_bar" ]
train
https://github.com/dropbox/pygerduty/blob/11b28bfb66306aa7fc2b95ab9df65eb97ea831cf/pygerduty/common.py#L72-L86
dropbox/pygerduty
pygerduty/__init__.py
Incident.reassign
def reassign(self, user_ids, requester_id): """Reassign this incident to a user or list of users :param user_ids: A non-empty list of user ids """ if not user_ids: raise Error('Must pass at least one user id') self._do_action('reassign', requester_id=requester_id, as...
python
def reassign(self, user_ids, requester_id): """Reassign this incident to a user or list of users :param user_ids: A non-empty list of user ids """ if not user_ids: raise Error('Must pass at least one user id') self._do_action('reassign', requester_id=requester_id, as...
[ "def", "reassign", "(", "self", ",", "user_ids", ",", "requester_id", ")", ":", "if", "not", "user_ids", ":", "raise", "Error", "(", "'Must pass at least one user id'", ")", "self", ".", "_do_action", "(", "'reassign'", ",", "requester_id", "=", "requester_id", ...
Reassign this incident to a user or list of users :param user_ids: A non-empty list of user ids
[ "Reassign", "this", "incident", "to", "a", "user", "or", "list", "of", "users" ]
train
https://github.com/dropbox/pygerduty/blob/11b28bfb66306aa7fc2b95ab9df65eb97ea831cf/pygerduty/__init__.py#L391-L398
dropbox/pygerduty
pygerduty/__init__.py
PagerDuty.acknowledge_incident
def acknowledge_incident(self, service_key, incident_key, description=None, details=None): """ Causes the referenced incident to enter the acknowledged state. Send an acknowledge event when someone is presently working on the incident. """ return sel...
python
def acknowledge_incident(self, service_key, incident_key, description=None, details=None): """ Causes the referenced incident to enter the acknowledged state. Send an acknowledge event when someone is presently working on the incident. """ return sel...
[ "def", "acknowledge_incident", "(", "self", ",", "service_key", ",", "incident_key", ",", "description", "=", "None", ",", "details", "=", "None", ")", ":", "return", "self", ".", "create_event", "(", "service_key", ",", "description", ",", "\"acknowledge\"", ...
Causes the referenced incident to enter the acknowledged state. Send an acknowledge event when someone is presently working on the incident.
[ "Causes", "the", "referenced", "incident", "to", "enter", "the", "acknowledged", "state", ".", "Send", "an", "acknowledge", "event", "when", "someone", "is", "presently", "working", "on", "the", "incident", "." ]
train
https://github.com/dropbox/pygerduty/blob/11b28bfb66306aa7fc2b95ab9df65eb97ea831cf/pygerduty/__init__.py#L573-L581
dropbox/pygerduty
pygerduty/__init__.py
PagerDuty.trigger_incident
def trigger_incident(self, service_key, description, incident_key=None, details=None, client=None, client_url=None, contexts=None): """ Report a new or ongoing problem. When PagerDuty receives a trigger, it will either open a new incident, or add a new l...
python
def trigger_incident(self, service_key, description, incident_key=None, details=None, client=None, client_url=None, contexts=None): """ Report a new or ongoing problem. When PagerDuty receives a trigger, it will either open a new incident, or add a new l...
[ "def", "trigger_incident", "(", "self", ",", "service_key", ",", "description", ",", "incident_key", "=", "None", ",", "details", "=", "None", ",", "client", "=", "None", ",", "client_url", "=", "None", ",", "contexts", "=", "None", ")", ":", "return", "...
Report a new or ongoing problem. When PagerDuty receives a trigger, it will either open a new incident, or add a new log entry to an existing incident.
[ "Report", "a", "new", "or", "ongoing", "problem", ".", "When", "PagerDuty", "receives", "a", "trigger", "it", "will", "either", "open", "a", "new", "incident", "or", "add", "a", "new", "log", "entry", "to", "an", "existing", "incident", "." ]
train
https://github.com/dropbox/pygerduty/blob/11b28bfb66306aa7fc2b95ab9df65eb97ea831cf/pygerduty/__init__.py#L583-L593
tanyaschlusser/array2gif
array2gif/core.py
check_dataset
def check_dataset(dataset): """Confirm shape (3 colors x rows x cols) and values [0 to 255] are OK.""" if isinstance(dataset, numpy.ndarray) and not len(dataset.shape) == 4: check_dataset_shape(dataset) check_dataset_range(dataset) else: # must be a list of arrays or a 4D NumPy array ...
python
def check_dataset(dataset): """Confirm shape (3 colors x rows x cols) and values [0 to 255] are OK.""" if isinstance(dataset, numpy.ndarray) and not len(dataset.shape) == 4: check_dataset_shape(dataset) check_dataset_range(dataset) else: # must be a list of arrays or a 4D NumPy array ...
[ "def", "check_dataset", "(", "dataset", ")", ":", "if", "isinstance", "(", "dataset", ",", "numpy", ".", "ndarray", ")", "and", "not", "len", "(", "dataset", ".", "shape", ")", "==", "4", ":", "check_dataset_shape", "(", "dataset", ")", "check_dataset_rang...
Confirm shape (3 colors x rows x cols) and values [0 to 255] are OK.
[ "Confirm", "shape", "(", "3", "colors", "x", "rows", "x", "cols", ")", "and", "values", "[", "0", "to", "255", "]", "are", "OK", "." ]
train
https://github.com/tanyaschlusser/array2gif/blob/b229da6c8e979314810f59ed0a15ea0f16f71243/array2gif/core.py#L55-L74
tanyaschlusser/array2gif
array2gif/core.py
try_fix_dataset
def try_fix_dataset(dataset): """Transpose the image data if it's in PIL format.""" if isinstance(dataset, numpy.ndarray): if len(dataset.shape) == 3: # NumPy 3D if dataset.shape[-1] == 3: return dataset.transpose((2, 0, 1)) elif len(dataset.shape) == 4: # NumPy 4D ...
python
def try_fix_dataset(dataset): """Transpose the image data if it's in PIL format.""" if isinstance(dataset, numpy.ndarray): if len(dataset.shape) == 3: # NumPy 3D if dataset.shape[-1] == 3: return dataset.transpose((2, 0, 1)) elif len(dataset.shape) == 4: # NumPy 4D ...
[ "def", "try_fix_dataset", "(", "dataset", ")", ":", "if", "isinstance", "(", "dataset", ",", "numpy", ".", "ndarray", ")", ":", "if", "len", "(", "dataset", ".", "shape", ")", "==", "3", ":", "# NumPy 3D", "if", "dataset", ".", "shape", "[", "-", "1"...
Transpose the image data if it's in PIL format.
[ "Transpose", "the", "image", "data", "if", "it", "s", "in", "PIL", "format", "." ]
train
https://github.com/tanyaschlusser/array2gif/blob/b229da6c8e979314810f59ed0a15ea0f16f71243/array2gif/core.py#L77-L95
tanyaschlusser/array2gif
array2gif/core.py
get_image
def get_image(dataset): """Convert the NumPy array to two nested lists with r,g,b tuples.""" dim, nrow, ncol = dataset.shape uint8_dataset = dataset.astype('uint8') if not (uint8_dataset == dataset).all(): message = ( "\nYour image was cast to a `uint8` (`<img>.astype(uint8)`), " ...
python
def get_image(dataset): """Convert the NumPy array to two nested lists with r,g,b tuples.""" dim, nrow, ncol = dataset.shape uint8_dataset = dataset.astype('uint8') if not (uint8_dataset == dataset).all(): message = ( "\nYour image was cast to a `uint8` (`<img>.astype(uint8)`), " ...
[ "def", "get_image", "(", "dataset", ")", ":", "dim", ",", "nrow", ",", "ncol", "=", "dataset", ".", "shape", "uint8_dataset", "=", "dataset", ".", "astype", "(", "'uint8'", ")", "if", "not", "(", "uint8_dataset", "==", "dataset", ")", ".", "all", "(", ...
Convert the NumPy array to two nested lists with r,g,b tuples.
[ "Convert", "the", "NumPy", "array", "to", "two", "nested", "lists", "with", "r", "g", "b", "tuples", "." ]
train
https://github.com/tanyaschlusser/array2gif/blob/b229da6c8e979314810f59ed0a15ea0f16f71243/array2gif/core.py#L98-L118
tanyaschlusser/array2gif
array2gif/core.py
get_color_table_size
def get_color_table_size(num_colors): """Total values in the color table is 2**(1 + int(result, base=2)). The result is a three-bit value (represented as a string with ones or zeros) that will become part of a packed byte encoding various details about the color table, used in the Logical Screen De...
python
def get_color_table_size(num_colors): """Total values in the color table is 2**(1 + int(result, base=2)). The result is a three-bit value (represented as a string with ones or zeros) that will become part of a packed byte encoding various details about the color table, used in the Logical Screen De...
[ "def", "get_color_table_size", "(", "num_colors", ")", ":", "nbits", "=", "max", "(", "math", ".", "ceil", "(", "math", ".", "log", "(", "num_colors", ",", "2", ")", ")", ",", "2", ")", "return", "'{:03b}'", ".", "format", "(", "int", "(", "nbits", ...
Total values in the color table is 2**(1 + int(result, base=2)). The result is a three-bit value (represented as a string with ones or zeros) that will become part of a packed byte encoding various details about the color table, used in the Logical Screen Descriptor block.
[ "Total", "values", "in", "the", "color", "table", "is", "2", "**", "(", "1", "+", "int", "(", "result", "base", "=", "2", "))", "." ]
train
https://github.com/tanyaschlusser/array2gif/blob/b229da6c8e979314810f59ed0a15ea0f16f71243/array2gif/core.py#L122-L131
tanyaschlusser/array2gif
array2gif/core.py
get_colors
def get_colors(image): """Return a Counter containing each color and how often it appears. """ colors = Counter(pixel for row in image for pixel in row) if len(colors) > 256: msg = ( "The maximum number of distinct colors in a GIF is 256 but " "this image has {} colors an...
python
def get_colors(image): """Return a Counter containing each color and how often it appears. """ colors = Counter(pixel for row in image for pixel in row) if len(colors) > 256: msg = ( "The maximum number of distinct colors in a GIF is 256 but " "this image has {} colors an...
[ "def", "get_colors", "(", "image", ")", ":", "colors", "=", "Counter", "(", "pixel", "for", "row", "in", "image", "for", "pixel", "in", "row", ")", "if", "len", "(", "colors", ")", ">", "256", ":", "msg", "=", "(", "\"The maximum number of distinct color...
Return a Counter containing each color and how often it appears.
[ "Return", "a", "Counter", "containing", "each", "color", "and", "how", "often", "it", "appears", "." ]
train
https://github.com/tanyaschlusser/array2gif/blob/b229da6c8e979314810f59ed0a15ea0f16f71243/array2gif/core.py#L167-L177
tanyaschlusser/array2gif
array2gif/core.py
_get_global_color_table
def _get_global_color_table(colors): """Return a color table sorted in descending order of count. """ global_color_table = b''.join(c[0] for c in colors.most_common()) full_table_size = 2**(1+int(get_color_table_size(len(colors)), 2)) repeats = 3 * (full_table_size - len(colors)) zeros = struct....
python
def _get_global_color_table(colors): """Return a color table sorted in descending order of count. """ global_color_table = b''.join(c[0] for c in colors.most_common()) full_table_size = 2**(1+int(get_color_table_size(len(colors)), 2)) repeats = 3 * (full_table_size - len(colors)) zeros = struct....
[ "def", "_get_global_color_table", "(", "colors", ")", ":", "global_color_table", "=", "b''", ".", "join", "(", "c", "[", "0", "]", "for", "c", "in", "colors", ".", "most_common", "(", ")", ")", "full_table_size", "=", "2", "**", "(", "1", "+", "int", ...
Return a color table sorted in descending order of count.
[ "Return", "a", "color", "table", "sorted", "in", "descending", "order", "of", "count", "." ]
train
https://github.com/tanyaschlusser/array2gif/blob/b229da6c8e979314810f59ed0a15ea0f16f71243/array2gif/core.py#L180-L187
tanyaschlusser/array2gif
array2gif/core.py
_get_image_data
def _get_image_data(image, colors): """Performs the LZW compression as described by Matthew Flickinger. This isn't fast, but it works. http://www.matthewflickinger.com/lab/whatsinagif/lzw_image_data.asp """ lzw_code_size, coded_bits = _lzw_encode(image, colors) coded_bytes = ''.join( '{...
python
def _get_image_data(image, colors): """Performs the LZW compression as described by Matthew Flickinger. This isn't fast, but it works. http://www.matthewflickinger.com/lab/whatsinagif/lzw_image_data.asp """ lzw_code_size, coded_bits = _lzw_encode(image, colors) coded_bytes = ''.join( '{...
[ "def", "_get_image_data", "(", "image", ",", "colors", ")", ":", "lzw_code_size", ",", "coded_bits", "=", "_lzw_encode", "(", "image", ",", "colors", ")", "coded_bytes", "=", "''", ".", "join", "(", "'{{:0{}b}}'", ".", "format", "(", "nbits", ")", ".", "...
Performs the LZW compression as described by Matthew Flickinger. This isn't fast, but it works. http://www.matthewflickinger.com/lab/whatsinagif/lzw_image_data.asp
[ "Performs", "the", "LZW", "compression", "as", "described", "by", "Matthew", "Flickinger", "." ]
train
https://github.com/tanyaschlusser/array2gif/blob/b229da6c8e979314810f59ed0a15ea0f16f71243/array2gif/core.py#L311-L339
tanyaschlusser/array2gif
array2gif/core.py
write_gif
def write_gif(dataset, filename, fps=10): """Write a NumPy array to GIF 89a format. Or write a list of NumPy arrays to an animation (GIF 89a format). - Positional arguments:: :param dataset: A NumPy arrayor list of arrays with shape rgb x rows x cols and integer values in ...
python
def write_gif(dataset, filename, fps=10): """Write a NumPy array to GIF 89a format. Or write a list of NumPy arrays to an animation (GIF 89a format). - Positional arguments:: :param dataset: A NumPy arrayor list of arrays with shape rgb x rows x cols and integer values in ...
[ "def", "write_gif", "(", "dataset", ",", "filename", ",", "fps", "=", "10", ")", ":", "try", ":", "check_dataset", "(", "dataset", ")", "except", "ValueError", "as", "e", ":", "dataset", "=", "try_fix_dataset", "(", "dataset", ")", "check_dataset", "(", ...
Write a NumPy array to GIF 89a format. Or write a list of NumPy arrays to an animation (GIF 89a format). - Positional arguments:: :param dataset: A NumPy arrayor list of arrays with shape rgb x rows x cols and integer values in [0, 255]. :param filename: The output fil...
[ "Write", "a", "NumPy", "array", "to", "GIF", "89a", "format", "." ]
train
https://github.com/tanyaschlusser/array2gif/blob/b229da6c8e979314810f59ed0a15ea0f16f71243/array2gif/core.py#L386-L426
mstuttgart/qdarkgraystyle
example/example_pyqt5.py
main
def main(): """ Application entry point """ logging.basicConfig(level=logging.DEBUG) # create the application and the main window app = QtWidgets.QApplication(sys.argv) window = QtWidgets.QMainWindow() # setup ui ui = example_ui.Ui_MainWindow() ui.setupUi(window) ui.bt_delay...
python
def main(): """ Application entry point """ logging.basicConfig(level=logging.DEBUG) # create the application and the main window app = QtWidgets.QApplication(sys.argv) window = QtWidgets.QMainWindow() # setup ui ui = example_ui.Ui_MainWindow() ui.setupUi(window) ui.bt_delay...
[ "def", "main", "(", ")", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "DEBUG", ")", "# create the application and the main window", "app", "=", "QtWidgets", ".", "QApplication", "(", "sys", ".", "argv", ")", "window", "=", "QtWidgets"...
Application entry point
[ "Application", "entry", "point" ]
train
https://github.com/mstuttgart/qdarkgraystyle/blob/d65182cfe4510fc507e80bfe974dd7faa5429cf0/example/example_pyqt5.py#L51-L89
mstuttgart/qdarkgraystyle
qdarkgraystyle/__init__.py
load_stylesheet
def load_stylesheet(): """ Loads the stylesheet for use in a pyqt5 application. :return the stylesheet string """ # Smart import of the rc file f = QtCore.QFile(':qdarkgraystyle/style.qss') if not f.exists(): _logger().error('Unable to load stylesheet, file not found in ' ...
python
def load_stylesheet(): """ Loads the stylesheet for use in a pyqt5 application. :return the stylesheet string """ # Smart import of the rc file f = QtCore.QFile(':qdarkgraystyle/style.qss') if not f.exists(): _logger().error('Unable to load stylesheet, file not found in ' ...
[ "def", "load_stylesheet", "(", ")", ":", "# Smart import of the rc file", "f", "=", "QtCore", ".", "QFile", "(", "':qdarkgraystyle/style.qss'", ")", "if", "not", "f", ".", "exists", "(", ")", ":", "_logger", "(", ")", ".", "error", "(", "'Unable to load styles...
Loads the stylesheet for use in a pyqt5 application. :return the stylesheet string
[ "Loads", "the", "stylesheet", "for", "use", "in", "a", "pyqt5", "application", ".", ":", "return", "the", "stylesheet", "string" ]
train
https://github.com/mstuttgart/qdarkgraystyle/blob/d65182cfe4510fc507e80bfe974dd7faa5429cf0/qdarkgraystyle/__init__.py#L48-L74
hovren/crisp
crisp/timesync.py
sync_camera_gyro
def sync_camera_gyro(image_sequence_or_flow, image_timestamps, gyro_data, gyro_timestamps, levels=6, full_output=False): """Get time offset that aligns image timestamps with gyro timestamps. Given an image sequence, and gyroscope data, with their respective timestamps, calculate the offset that aligns ...
python
def sync_camera_gyro(image_sequence_or_flow, image_timestamps, gyro_data, gyro_timestamps, levels=6, full_output=False): """Get time offset that aligns image timestamps with gyro timestamps. Given an image sequence, and gyroscope data, with their respective timestamps, calculate the offset that aligns ...
[ "def", "sync_camera_gyro", "(", "image_sequence_or_flow", ",", "image_timestamps", ",", "gyro_data", ",", "gyro_timestamps", ",", "levels", "=", "6", ",", "full_output", "=", "False", ")", ":", "# If input is not flow, then create from iamge sequence", "try", ":", "asse...
Get time offset that aligns image timestamps with gyro timestamps. Given an image sequence, and gyroscope data, with their respective timestamps, calculate the offset that aligns the image data with the gyro data. The timestamps must only differ by an offset, not a scale factor. This function find...
[ "Get", "time", "offset", "that", "aligns", "image", "timestamps", "with", "gyro", "timestamps", ".", "Given", "an", "image", "sequence", "and", "gyroscope", "data", "with", "their", "respective", "timestamps", "calculate", "the", "offset", "that", "aligns", "the...
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/timesync.py#L36-L120
hovren/crisp
crisp/timesync.py
sync_camera_gyro_manual
def sync_camera_gyro_manual(image_sequence, image_timestamps, gyro_data, gyro_timestamps, full_output=False): """Get time offset that aligns image timestamps with gyro timestamps. Given an image sequence, and gyroscope data, with their respective timestamps, calculate the offset that aligns the image d...
python
def sync_camera_gyro_manual(image_sequence, image_timestamps, gyro_data, gyro_timestamps, full_output=False): """Get time offset that aligns image timestamps with gyro timestamps. Given an image sequence, and gyroscope data, with their respective timestamps, calculate the offset that aligns the image d...
[ "def", "sync_camera_gyro_manual", "(", "image_sequence", ",", "image_timestamps", ",", "gyro_data", ",", "gyro_timestamps", ",", "full_output", "=", "False", ")", ":", "flow", "=", "tracking", ".", "optical_flow_magnitude", "(", "image_sequence", ")", "flow_timestamps...
Get time offset that aligns image timestamps with gyro timestamps. Given an image sequence, and gyroscope data, with their respective timestamps, calculate the offset that aligns the image data with the gyro data. The timestamps must only differ by an offset, not a scale factor. This function find...
[ "Get", "time", "offset", "that", "aligns", "image", "timestamps", "with", "gyro", "timestamps", ".", "Given", "an", "image", "sequence", "and", "gyroscope", "data", "with", "their", "respective", "timestamps", "calculate", "the", "offset", "that", "aligns", "the...
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/timesync.py#L124-L210
hovren/crisp
crisp/timesync.py
refine_time_offset
def refine_time_offset(image_list, frame_timestamps, rotation_sequence, rotation_timestamps, camera_matrix, readout_time): """Refine a time offset between camera and IMU using rolling shutter aware optimization. To refine the time offset using this function, you must meet the following constraints ...
python
def refine_time_offset(image_list, frame_timestamps, rotation_sequence, rotation_timestamps, camera_matrix, readout_time): """Refine a time offset between camera and IMU using rolling shutter aware optimization. To refine the time offset using this function, you must meet the following constraints ...
[ "def", "refine_time_offset", "(", "image_list", ",", "frame_timestamps", ",", "rotation_sequence", ",", "rotation_timestamps", ",", "camera_matrix", ",", "readout_time", ")", ":", "# ) Track points", "max_corners", "=", "200", "quality_level", "=", "0.07", "min_distance...
Refine a time offset between camera and IMU using rolling shutter aware optimization. To refine the time offset using this function, you must meet the following constraints 1) The data must already be roughly aligned. Only a few image frames of error is allowed. 2) The images *must* have b...
[ "Refine", "a", "time", "offset", "between", "camera", "and", "IMU", "using", "rolling", "shutter", "aware", "optimization", ".", "To", "refine", "the", "time", "offset", "using", "this", "function", "you", "must", "meet", "the", "following", "constraints", "1"...
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/timesync.py#L243-L333
hovren/crisp
crisp/timesync.py
good_sequences_to_track
def good_sequences_to_track(flow, motion_threshold=1.0): """Get list of good frames to do tracking in. Looking at the optical flow, this function chooses a span of frames that fulfill certain criteria. These include * not being too short or too long * not too low or too high mean flow m...
python
def good_sequences_to_track(flow, motion_threshold=1.0): """Get list of good frames to do tracking in. Looking at the optical flow, this function chooses a span of frames that fulfill certain criteria. These include * not being too short or too long * not too low or too high mean flow m...
[ "def", "good_sequences_to_track", "(", "flow", ",", "motion_threshold", "=", "1.0", ")", ":", "endpoints", "=", "[", "]", "in_low", "=", "False", "for", "i", ",", "val", "in", "enumerate", "(", "flow", ")", ":", "if", "val", "<", "motion_threshold", ":",...
Get list of good frames to do tracking in. Looking at the optical flow, this function chooses a span of frames that fulfill certain criteria. These include * not being too short or too long * not too low or too high mean flow magnitude * a low max value (avoids motion blur) Curr...
[ "Get", "list", "of", "good", "frames", "to", "do", "tracking", "in", "." ]
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/timesync.py#L336-L411
hovren/crisp
crisp/calibration.py
AutoCalibrator.initialize
def initialize(self, gyro_rate, slices=None, skip_estimation=False): """Prepare calibrator for calibration This method does three things: 1. Create slices from the video stream, if not already provided 2. Estimate time offset 3. Estimate rotation between camera and gyroscope ...
python
def initialize(self, gyro_rate, slices=None, skip_estimation=False): """Prepare calibrator for calibration This method does three things: 1. Create slices from the video stream, if not already provided 2. Estimate time offset 3. Estimate rotation between camera and gyroscope ...
[ "def", "initialize", "(", "self", ",", "gyro_rate", ",", "slices", "=", "None", ",", "skip_estimation", "=", "False", ")", ":", "self", ".", "params", "[", "'user'", "]", "[", "'gyro_rate'", "]", "=", "gyro_rate", "for", "p", "in", "(", "'gbias_x'", ",...
Prepare calibrator for calibration This method does three things: 1. Create slices from the video stream, if not already provided 2. Estimate time offset 3. Estimate rotation between camera and gyroscope Parameters ------------------ gyro_rate : float ...
[ "Prepare", "calibrator", "for", "calibration" ]
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/calibration.py#L90-L134
hovren/crisp
crisp/calibration.py
AutoCalibrator.video_time_to_gyro_sample
def video_time_to_gyro_sample(self, t): """Convert video time to gyroscope sample index and interpolation factor Parameters ------------------- t : float Video timestamp Returns -------------------- n : int Sample index that precedes t ...
python
def video_time_to_gyro_sample(self, t): """Convert video time to gyroscope sample index and interpolation factor Parameters ------------------- t : float Video timestamp Returns -------------------- n : int Sample index that precedes t ...
[ "def", "video_time_to_gyro_sample", "(", "self", ",", "t", ")", ":", "f_g", "=", "self", ".", "parameter", "[", "'gyro_rate'", "]", "d_c", "=", "self", ".", "parameter", "[", "'time_offset'", "]", "n", "=", "f_g", "*", "(", "t", "+", "d_c", ")", "n0"...
Convert video time to gyroscope sample index and interpolation factor Parameters ------------------- t : float Video timestamp Returns -------------------- n : int Sample index that precedes t tau : float Interpolation factor ...
[ "Convert", "video", "time", "to", "gyroscope", "sample", "index", "and", "interpolation", "factor" ]
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/calibration.py#L137-L157
hovren/crisp
crisp/calibration.py
AutoCalibrator.parameter
def parameter(self): """Return the current best value of a parameter""" D = {} for source in PARAM_SOURCE_ORDER: D.update(self.params[source]) return D
python
def parameter(self): """Return the current best value of a parameter""" D = {} for source in PARAM_SOURCE_ORDER: D.update(self.params[source]) return D
[ "def", "parameter", "(", "self", ")", ":", "D", "=", "{", "}", "for", "source", "in", "PARAM_SOURCE_ORDER", ":", "D", ".", "update", "(", "self", ".", "params", "[", "source", "]", ")", "return", "D" ]
Return the current best value of a parameter
[ "Return", "the", "current", "best", "value", "of", "a", "parameter" ]
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/calibration.py#L160-L165
hovren/crisp
crisp/calibration.py
AutoCalibrator.calibrate
def calibrate(self, max_tracks=MAX_OPTIMIZATION_TRACKS, max_eval=MAX_OPTIMIZATION_FEV, norm_c=DEFAULT_NORM_C): """Perform calibration Parameters ---------------------- max_eval : int Maximum number of function evaluations Returns --------------------- ...
python
def calibrate(self, max_tracks=MAX_OPTIMIZATION_TRACKS, max_eval=MAX_OPTIMIZATION_FEV, norm_c=DEFAULT_NORM_C): """Perform calibration Parameters ---------------------- max_eval : int Maximum number of function evaluations Returns --------------------- ...
[ "def", "calibrate", "(", "self", ",", "max_tracks", "=", "MAX_OPTIMIZATION_TRACKS", ",", "max_eval", "=", "MAX_OPTIMIZATION_FEV", ",", "norm_c", "=", "DEFAULT_NORM_C", ")", ":", "x0", "=", "np", ".", "array", "(", "[", "self", ".", "parameter", "[", "param",...
Perform calibration Parameters ---------------------- max_eval : int Maximum number of function evaluations Returns --------------------- dict Optimization result Raises ----------------------- CalibrationError ...
[ "Perform", "calibration" ]
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/calibration.py#L167-L209
hovren/crisp
crisp/calibration.py
AutoCalibrator.find_initial_offset
def find_initial_offset(self, pyramids=6): """Estimate time offset This sets and returns the initial time offset estimation. Parameters --------------- pyramids : int Number of pyramids to use for ZNCC calculations. If initial estimation ...
python
def find_initial_offset(self, pyramids=6): """Estimate time offset This sets and returns the initial time offset estimation. Parameters --------------- pyramids : int Number of pyramids to use for ZNCC calculations. If initial estimation ...
[ "def", "find_initial_offset", "(", "self", ",", "pyramids", "=", "6", ")", ":", "flow", "=", "self", ".", "video", ".", "flow", "gyro_rate", "=", "self", ".", "parameter", "[", "'gyro_rate'", "]", "frame_times", "=", "np", ".", "arange", "(", "len", "(...
Estimate time offset This sets and returns the initial time offset estimation. Parameters --------------- pyramids : int Number of pyramids to use for ZNCC calculations. If initial estimation of time offset fails, try lowering this value. ...
[ "Estimate", "time", "offset", "This", "sets", "and", "returns", "the", "initial", "time", "offset", "estimation", ".", "Parameters", "---------------", "pyramids", ":", "int", "Number", "of", "pyramids", "to", "use", "for", "ZNCC", "calculations", ".", "If", "...
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/calibration.py#L211-L236
hovren/crisp
crisp/calibration.py
AutoCalibrator.find_initial_rotation
def find_initial_rotation(self): """Estimate rotation between camera and gyroscope This sets and returns the initial rotation estimate. Note that the initial time offset must have been estimated before calling this function! Returns -------------------- (3,3) n...
python
def find_initial_rotation(self): """Estimate rotation between camera and gyroscope This sets and returns the initial rotation estimate. Note that the initial time offset must have been estimated before calling this function! Returns -------------------- (3,3) n...
[ "def", "find_initial_rotation", "(", "self", ")", ":", "if", "'time_offset'", "not", "in", "self", ".", "parameter", ":", "raise", "InitializationError", "(", "\"Can not estimate rotation without an estimate of time offset. Please estimate the offset and try again.\"", ")", "dt...
Estimate rotation between camera and gyroscope This sets and returns the initial rotation estimate. Note that the initial time offset must have been estimated before calling this function! Returns -------------------- (3,3) ndarray Estimated rotation betwee...
[ "Estimate", "rotation", "between", "camera", "and", "gyroscope", "This", "sets", "and", "returns", "the", "initial", "rotation", "estimate", ".", "Note", "that", "the", "initial", "time", "offset", "must", "have", "been", "estimated", "before", "calling", "this"...
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/calibration.py#L238-L326
hovren/crisp
crisp/calibration.py
AutoCalibrator.print_params
def print_params(self): """Print the current best set of parameters""" print("Parameters") print("--------------------") for param in PARAM_ORDER: print(' {:>11s} = {}'.format(param, self.parameter[param]))
python
def print_params(self): """Print the current best set of parameters""" print("Parameters") print("--------------------") for param in PARAM_ORDER: print(' {:>11s} = {}'.format(param, self.parameter[param]))
[ "def", "print_params", "(", "self", ")", ":", "print", "(", "\"Parameters\"", ")", "print", "(", "\"--------------------\"", ")", "for", "param", "in", "PARAM_ORDER", ":", "print", "(", "' {:>11s} = {}'", ".", "format", "(", "param", ",", "self", ".", "para...
Print the current best set of parameters
[ "Print", "the", "current", "best", "set", "of", "parameters" ]
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/calibration.py#L328-L333
hovren/crisp
crisp/remove_slp.py
remove_slp
def remove_slp(img, gstd1=GSTD1, gstd2=GSTD2, gstd3=GSTD3, ksize=KSIZE, w=W): """Remove the SLP from kinect IR image The input image should be a float32 numpy array, and should NOT be a square root image Parameters ------------------ img : (M, N) float ndarray Kinect NIR image with ...
python
def remove_slp(img, gstd1=GSTD1, gstd2=GSTD2, gstd3=GSTD3, ksize=KSIZE, w=W): """Remove the SLP from kinect IR image The input image should be a float32 numpy array, and should NOT be a square root image Parameters ------------------ img : (M, N) float ndarray Kinect NIR image with ...
[ "def", "remove_slp", "(", "img", ",", "gstd1", "=", "GSTD1", ",", "gstd2", "=", "GSTD2", ",", "gstd3", "=", "GSTD3", ",", "ksize", "=", "KSIZE", ",", "w", "=", "W", ")", ":", "gf1", "=", "cv2", ".", "getGaussianKernel", "(", "ksize", ",", "gstd1", ...
Remove the SLP from kinect IR image The input image should be a float32 numpy array, and should NOT be a square root image Parameters ------------------ img : (M, N) float ndarray Kinect NIR image with SLP pattern gstd1 : float Standard deviation of gaussian kernel 1 ...
[ "Remove", "the", "SLP", "from", "kinect", "IR", "image", "The", "input", "image", "should", "be", "a", "float32", "numpy", "array", "and", "should", "NOT", "be", "a", "square", "root", "image", "Parameters", "------------------", "img", ":", "(", "M", "N",...
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/remove_slp.py#L37-L74
hovren/crisp
crisp/camera.py
AtanCameraModel.from_hdf
def from_hdf(cls, filename): """Load camera model params from a HDF5 file The HDF5 file should contain the following datasets: wc : (2,) float with distortion center lgamma : float distortion parameter readout : float readout value size : (2,) int image s...
python
def from_hdf(cls, filename): """Load camera model params from a HDF5 file The HDF5 file should contain the following datasets: wc : (2,) float with distortion center lgamma : float distortion parameter readout : float readout value size : (2,) int image s...
[ "def", "from_hdf", "(", "cls", ",", "filename", ")", ":", "import", "h5py", "with", "h5py", ".", "File", "(", "filename", ",", "'r'", ")", "as", "f", ":", "wc", "=", "f", "[", "\"wc\"", "]", ".", "value", "lgamma", "=", "f", "[", "\"lgamma\"", "]...
Load camera model params from a HDF5 file The HDF5 file should contain the following datasets: wc : (2,) float with distortion center lgamma : float distortion parameter readout : float readout value size : (2,) int image size fps : float frame rate ...
[ "Load", "camera", "model", "params", "from", "a", "HDF5", "file" ]
train
https://github.com/hovren/crisp/blob/65cae19e7cfae5a397859096c9ef666e0f4e7f1b/crisp/camera.py#L128-L158