Search is not available for this dataset
text
stringlengths
75
104k
async def play(self, *uris: SomeURIs, offset: Optional[Offset] = 0, device: Optional[SomeDevice] = None): """Start a new context or resume current playback on the user’s active device. The method treats a single argument as a Spotify context, such as a Artist, Album and playlist objects/URI. Wh...
async def shuffle(self, state: Optional[bool] = None, *, device: Optional[SomeDevice] = None): """shuffle on or off for user’s playback. Parameters ---------- state : Optional[bool] if `True` then Shuffle user’s playback. else if `False` do not shuffle user’s pla...
async def transfer(self, device: SomeDevice, ensure_playback: bool = False): """Transfer playback to a new device and determine if it should start playing. Parameters ---------- device : :obj:`SomeDevice` The device on which playback should be started/transferred. en...
async def from_href(self): """Get the full object from spotify with a `href` attribute.""" if not hasattr(self, 'href'): raise TypeError('Spotify object has no `href` attribute, therefore cannot be retrived') elif hasattr(self, 'http'): return await self.http.request(('G...
def get(self): # pragma: no cover """ Execute the logic behind the meaning of ExpirationDate + return the matched status. :return: The status of the tested domain. Can be one of the official status. :rtype: str """ # We get the status of the dom...
def _convert_or_shorten_month(cls, data): """ Convert a given month into our unified format. :param data: The month to convert or shorten. :type data: str :return: The unified month name. :rtype: str """ # We map the different month and their possible r...
def _cases_management(self, regex_number, matched_result): """ A little internal helper of self.format. (Avoiding of nested loops) .. note:: Please note that the second value of the case represent the groups in order :code:`[day,month,year]`. This means that...
def _format(self, date_to_convert=None): """ Format the expiration date into an unified format (01-jan-1970). :param date_to_convert: The date to convert. In other words, the extracted date. :type date_to_convert: str :return: The formatted expiration date. ...
def _extract(self): # pragma: no cover """ Extract the expiration date from the whois record. :return: The status of the domain. :rtype: str """ # We try to get the expiration date from the database. expiration_date_from_database = Whois().get_expiration_date()...
def _update_code_urls(self): """ Read the code and update all links. """ to_ignore = [".gitignore", ".keep"] for root, _, files in PyFunceble.walk( PyFunceble.CURRENT_DIRECTORY + PyFunceble.directory_separator + "PyFunceble" + PyF...
def _is_version_greater(self): """ Check if the current version is greater as the older older one. """ # we compare the 2 versions. checked = Version(True).check_versions( self.current_version[0], self.version_yaml ) if checked is not None and not ch...
def is_dev_version(cls): """ Check if the current branch is `dev`. """ # We initiate the command we have to run in order to # get the branch we are currently working with. command = "git branch" # We execute and get the command output. command_result = C...
def _does_require_deprecation(self): """ Check if we have to put the previous version into the deprecated list. """ for index, version_number in enumerate(self.current_version[0][:2]): # We loop through the 2 last elements of the version. if version_number > sel...
def _update_docs(self, file_to_update): """ Update the given documentation file or :code:`README.rst` so that it always gives branch related URL and informations. .. note:: This only apply to :code:`dev` and :code:`master` branch. :param file_to_update: The file to ...
def _update_setup_py(self): """ Update :code:`setup.py` so that it always have the right name. """ # We initiate the path to the file we have to filter. setup_py_path = PyFunceble.CURRENT_DIRECTORY + "setup.py" if self.is_dev_version(): # The current version...
def _update_travis_yml(self): """ Update :code:`.travis.yml` according to current branch. """ # We initiate the file we have to filter/update. travis_yml_path = PyFunceble.CURRENT_DIRECTORY + ".travis.yml" if self.is_dev_version(): # The current version is t...
def backup(self): """ Backup the current execution state. """ if PyFunceble.CONFIGURATION["auto_continue"]: # The auto_continue subsystem is activated. # We initiate the location where we are going to save the data to backup. data_to_backup = {} ...
def restore(self): """ Restore data from the given path. """ if PyFunceble.CONFIGURATION["auto_continue"] and self.backup_content: # The auto_continue subsystem is activated and the backup_content # is not empty. # We get the file we have to restore....
def _is_to_ignore(cls, line): """ Check if we have to ignore the given line. :param line: The line from the file. :type line: str """ # We set the list of regex to match to be # considered as ignored. to_ignore = [r"(^!|^@@|^\/|^\[|^\.|^-|^_|^\?|^&)"] #...
def _handle_options(self, options): """ Handle the data from the options. :param options: The list of options from the rule. :type options: list :return: The list of domains to return globally. :rtype: list """ # We initiate a variable which will save o...
def _extract_base(self, element): """ Extract the base of the given element. .. example: given "hello/world?world=beautiful" return "hello" :param element: The element we are working with. :type element: str|list """ if isinstance(element, list): ...
def decode(self): """ Decode/extract the domains to test from the adblock formated file. :return: The list of domains to test. :rtype: list """ # We initiate a variable which will save what we are going to return. result = [] # We initiate the first reg...
def _format_decoded(self, to_format, result=None): # pragma: no cover """ Format the exctracted adblock line before passing it to the system. :param to_format: The extracted line from the file. :type to_format: str :param result: A list of the result of this method. :t...
def _access(self): # pragma: no cover """ Get the HTTP code status. :return: The matched HTTP status code. :rtype: int|None """ try: # We try to get the HTTP status code. if PyFunceble.INTERN["to_test_type"] == "url": # We are g...
def get(self): """ Return the HTTP code status. :return: The matched and formatted status code. :rtype: str|int|None """ if PyFunceble.HTTP_CODE["active"]: # The http status code extraction is activated. # We get the http status code. ...
def syntax_check(domain): # pragma: no cover """ Check the syntax of the given domain. :param domain: The domain to check the syntax for. :type domain: str :return: The syntax validity. :rtype: bool .. warning:: If an empty or a non-string :code:`domain` is given, we return :code...
def is_subdomain(domain): # pragma: no cover """ Check if the given domain is a subdomain. :param domain: The domain we are checking. :type domain: str :return: The subdomain state. :rtype: bool .. warning:: If an empty or a non-string :code:`domain` is given, we return :code:`No...
def ipv4_syntax_check(ip): # pragma: no cover """ Check the syntax of the given IPv4. :param ip: The IPv4 to check the syntax for. :type ip: str :return: The syntax validity. :rtype: bool .. warning:: If an empty or a non-string :code:`ip` is given, we return :code:`None`. ""...
def is_ipv4_range(ip): # pragma: no cover """ Check if the given IP is an IP range. :param ip: The IP we are checking. :type ip: str :return: The IPv4 range state. :rtype: bool .. warning:: If an empty or a non-string :code:`ip` is given, we return :code:`None`. """ if i...
def url_syntax_check(url): # pragma: no cover """ Check the syntax of the given URL. :param url: The URL to check the syntax for. :type url: str :return: The syntax validity. :rtype: bool .. warning:: If an empty or a non-string :code:`url` is given, we return :code:`None`. "...
def load_config(under_test=False, custom=None): # pragma: no cover """ Load the configuration. :param under_test: Tell us if we only have to load the configuration file (True) or load the configuration file and initate the output directory if it does not exist (False). :type un...
def stay_safe(): # pragma: no cover """ Print a friendly message. """ random = int(choice(str(int(time())))) if not CONFIGURATION["quiet"] and random % 3 == 0: print("\n" + Fore.GREEN + Style.BRIGHT + "Thanks for using PyFunceble!") print( Fore.YELLOW + Sty...
def _command_line(): # pragma: no cover pylint: disable=too-many-branches,too-many-statements """ Provide the command line interface. """ if __name__ == "PyFunceble": # We initiate the end of the coloration at the end of each line. initiate(autoreset=True) # We load the config...
def _entry_management_url_download(self, passed): """ Check if the given information is a URL. If it is the case, it download and update the location of file to test. :param passed: The url passed to the system. :type passed: str :return: The state of the check. ...
def _entry_management_url(self): """ Manage the loading of the url system. """ if ( self.url_file # pylint: disable=no-member and not self._entry_management_url_download( self.url_file # pylint: disable=no-member ) ): # pyli...
def _entry_management(self): # pylint: disable=too-many-branches """ Avoid to have 1 millions line into self.__init__() """ if not self.modulo_test: # pylint: disable=no-member # We are not in a module usage. # We set the file_path as the file we have to test....
def bypass(cls): """ Exit the script if :code:`[PyFunceble skip]` is matched into the latest commit message. """ # We set the regex to match in order to bypass the execution of # PyFunceble. regex_bypass = r"\[PyFunceble\sskip\]" if ( PyFunce...
def _print_header(cls): """ Decide if we print or not the header. """ if ( not PyFunceble.CONFIGURATION["quiet"] and not PyFunceble.CONFIGURATION["header_printed"] ): # * The quiet mode is not activated. # and # * The h...
def _file_decision(self, current, last, status=None): """ Manage the database, autosave and autocontinue systems for the case that we are reading a file. :param current: The currently tested element. :type current: str :param last: The last element of the list. ...
def domain(self, domain=None, last_domain=None): """ Manage the case that we want to test only a domain. :param domain: The domain or IP to test. :type domain: str :param last_domain: The last domain to test if we are testing a file. :type last_domain: str ...
def url(self, url_to_test=None, last_url=None): """ Manage the case that we want to test only a given url. :param url_to_test: The url to test. :type url_to_test: str :param last_url: The last url of the file we are testing (if exist) :type last_...
def colorify_logo(cls, home=False): """ Print the colored logo based on global results. :param home: Tell us if we have to print the initial coloration. :type home: bool """ if not PyFunceble.CONFIGURATION["quiet"]: # The quiet mode is not activated. ...
def _format_domain(cls, extracted_domain): """ Format the extracted domain before passing it to the system. :param extracted_domain: The extracted domain. :type extracted_domain: str :return: The formatted domain or IP to test. :rtype: str .. note: ...
def _extract_domain_from_file(cls): """ Extract all non commented lines from the file we are testing. :return: The elements to test. :rtype: list """ # We initiate the variable which will save what we are going to return. result = [] if PyFunceble.path....
def file(self): """ Manage the case that need to test each domain of a given file path. .. note:: 1 domain per line. """ # We get, format, filter, clean the list to test. list_to_test = self._file_list_to_test_filtering() if PyFunceble.CONFIGURATION...
def file_url(self): """ Manage the case that we have to test a file .. note:: 1 URL per line. """ # We get, format, clean the list of URL to test. list_to_test = self._file_list_to_test_filtering() # We initiate a local variable which will save the ...
def switch( cls, variable, custom=False ): # pylint: disable=inconsistent-return-statements """ Switch PyFunceble.CONFIGURATION variables to their opposite. :param variable: The variable name to switch. The variable should be an index our configuration syste...
def get(cls): """ Get the status while testing for an IP or domain. .. note:: We consider that the domain or IP we are currently testing is into :code:`PyFunceble.INTERN["to_test"]`. """ if "to_test" in PyFunceble.INTERN and PyFunceble.INTERN["to_test"]:...
def handle(cls, status, invalid_source="IANA"): """ Handle the lack of WHOIS and expiration date. :smile_cat: :param matched_status: The status that we have to handle. :type status: str :param invalid_source: The source to set when we handle INVALID element. ...
def handle(self): """ Handle the backend of the given status. """ # We initiate the source we are going to parse to the Generate class. source = "URL" if self.catched.lower() not in PyFunceble.STATUS["list"]["invalid"]: # The parsed status is not in the list...
def backup(self): """ Backup the developer state of `output/` in order to make it restorable and portable for user. """ # We set the current output directory path. output_path = self.base + PyFunceble.OUTPUTS["parent_directory"] # We initiate the structure b...
def _restore_replace(self): """ Check if we need to replace ".gitignore" to ".keep". :return: The replacement status. :rtype: bool """ if PyFunceble.path.isdir(self.base + ".git"): # The `.git` directory exist. if "PyFunceble" not in Command("gi...
def _update_structure_from_config(self, structure): """ Update the paths according to configs. :param structure: The read structure. :type structure: dict """ # We initiate a variable which will map what we have to replace `ouput` to. # Indeed, as we allow the u...
def _get_structure(self): """ Get the structure we are going to work with. :return: The structure we have to work with. :rtype: dict """ # We initiate an empty variable which is going to save the location of # file we are going to download. structure_fil...
def _create_directory(cls, directory, loop=False): """ Creates the given directory if it does not exists. :param directory: The directory to create. :type directory: str :param loop: Tell us if we are in the creation loop or not. :type loop: bool """ if...
def restore(self): """ Restore the 'output/' directory structure based on the `dir_structure.json` file. """ # We get the structure we have to create/apply. structure = self._get_structure() # We get the list of key which is implicitly the list of directory to recreate....
def delete_uneeded(self): """ Delete the directory which are not registered into our structure. """ # We get the structure we have to apply. structure = self._get_structure() # We get the list of key which is implicitly the list of directory we do not bave to delete. ...
def _set_path_to_configs(cls, path_to_config): """ Set the paths to the configuration files. :param path_to_config: The possible path to the config to load. :type path_to_config: str :return: The path to the config to read (0), the path to the default co...
def _load_config_file(self): """ Load .PyFunceble.yaml into the system. """ try: # We try to load the configuration file. PyFunceble.CONFIGURATION.update( Dict.from_yaml(File(self.path_to_config).read()) ) # We install th...
def _install_production_config(self): """ Download the production configuration and install it in the current directory. """ # We initiate the link to the production configuration. # It is not hard coded because this method is called only if we # are sure that th...
def _install_iana_config(cls): """ Download `iana-domains-db.json` if not present. """ # We initiate the link to the iana configuration. # It is not hard coded because this method is called only if we # are sure that the configuration file exist. iana_link = PyFu...
def _install_psl_config(cls): """ Download `public-suffix.json` if not present. """ # We initiate the link to the public suffix configuration. # It is not hard coded because this method is called only if we # are sure that the configuration file exist. psl_link =...
def _install_directory_structure_file(cls): """ Download the latest version of `dir_structure_production.json`. """ # We initiate the link to the public suffix configuration. # It is not hard coded because this method is called only if we # are sure that the configuratio...
def _merge_values(self): """ Simply merge the older into the new one. """ to_remove = [] self.new_config = Dict( Dict(self.upstream_config).merge(PyFunceble.CONFIGURATION) ).remove_key(to_remove)
def _load(self): """ Execute the logic behind the merging. """ if "PYFUNCEBLE_AUTO_CONFIGURATION" not in PyFunceble.environ: # The auto configuration environment variable is not set. while True: # We infinitly loop until we get a reponse which is...
def split_versions(cls, version, return_non_digits=False): """ Convert the versions to a shorter one. :param version: The version to split. :type version: str :param return_non_digits: Activate the return of the non-digits parts of the splitted version. ...
def check_versions(cls, local, upstream): """ Compare the given versions. :param local: The local version converted by split_versions(). :type local: list :param upstream: The upstream version converted by split_versions(). :type upstream: list :return: ...
def compare(self): """ Compare the current version with the upstream saved version. """ if self.upstream_data["force_update"]["status"]: # The force_update status is set to True. for minimal in self.upstream_data["force_update"]["minimal_version"]: ...
def is_cloned(cls): """ Let us know if we are currently in the cloned version of PyFunceble which implicitly mean that we are in developement mode. """ if not PyFunceble.path.isdir(".git"): # The git directory does not exist. # We return False, the curre...
def _handle_non_existant_index(cls): """ Handle and check that some configuration index exists. """ try: # We try to call the http code. PyFunceble.INTERN["http_code"] except KeyError: # If it is not found. # We initiate an empty ...
def _analytic_host_file_directory(self): """ Return the analytic directory to write depending of the matched status. """ # We construct the path to the analytic directory. output_dir = ( self.output_parent_dir + PyFunceble.OUTPUTS["analytic"]["dir...
def info_files(self): # pylint: disable=inconsistent-return-statements """ Generate the hosts file, the plain list and the splitted lists. """ if self._do_not_produce_file(): # We do not have to produce file. # We return false. return False ...
def unified_file(self): """ Generate unified file. Understand by that that we use an unified table instead of a separate table for each status which could result into a misunderstanding. """ if ( "file_to_test" in PyFunceble.INTERN and PyFunceble....
def analytic_file(self, new_status, old_status=None): """ Generate :code:`Analytic/*` files based on the given old and new statuses. :param new_status: The new status of the domain. :type new_status: str :param old_status: The old status of the domain. :type old...
def _prints_status_file(self): # pylint: disable=too-many-branches """ Logic behind the printing (in file) when generating status file. """ if PyFunceble.INTERN["file_to_test"]: # We are testing a file. output = ( self.output_parent_dir ...
def _prints_status_screen(self): """ Logic behind the printing (on screen) when generating status file. """ if not PyFunceble.CONFIGURATION["quiet"]: # The quiet mode is not activated. if PyFunceble.CONFIGURATION["less"]: # We have to print less ...
def status_file(self): # pylint: disable=inconsistent-return-statements """ Generate a file according to the domain status. """ if "file_to_test" in PyFunceble.INTERN: # We are not testing as an imported module. # We generate the hosts file. Generat...
def _do_not_produce_file(self): """ Check if we are allowed to produce a file based from the given information. :return: The state of the production. True: We do not produce file. False: We do produce file. :rtype: bool """ if...
def _extensions(self, line): """ Extract the extension from the given line. :param line: The line from the official public suffix repository. :type line: str """ # We strip the parsed line. line = line.strip() if not line.startswith("//") and "." in lin...
def update(self): """ Update of the content of the :code:`public-suffix.json`. """ if not PyFunceble.CONFIGURATION["quiet"]: # The quiet mode is not activated. # We print a message for the user on screen. print( "Update of %s" % PyFun...
def load(self): """ Load the public suffix database into the system. """ if not PyFunceble.INTERN["psl_db"]: # The public database was not already loaded. # * We read, convert to dict and return the file content. # and # * We fill/create ...
def standard(cls, element): """ Implement the standard and alphabetical sorting. :param element: The element we are currently reading. :type element: str :return: The formatted element. :rtype: str """ # We remove all special characters and return the f...
def hierarchical(cls, element): """ The idea behind this method is to sort a list of domain hierarchicaly. :param element: The element we are currently reading. :type element: str :return: The formatted element. :rtype: str .. note:: For a domain li...
def load(self): """ Initiate the IANA database if it is not the case. """ if "iana_db" not in PyFunceble.INTERN or not PyFunceble.INTERN["iana_db"]: # The global database is empty, None or does not exist. # We update it with the database content. PyF...
def _referer(self, extension): """ Return the referer for the given extension. :param extension: A valid domain extension. :type extension: str :return: The whois server to use to get the WHOIS record. :rtype: str """ # We get the a copy of the page. ...
def _extensions(self): """ Extract the extention from the given block. Plus get its referer. """ upstream_lines = ( Download(self.iana_url, return_data=True) .text() .split('<span class="domain tld">') ) # We extract the diffe...
def update(self): """ Update the content of the `iana-domains-db` file. """ if not PyFunceble.CONFIGURATION["quiet"]: # * The quiet mode is not activated. # We print on screen what we are doing. print("Update of iana-domains-db", end=" ") # ...
def mine(self): # pragma: no cover """ Search for domain or URL related to the original URL or domain. :return: The mined domains or URL. :rtype: dict """ if PyFunceble.CONFIGURATION["mining"]: # The mining is activated. try: # ...
def _retrieve(self): """ Retrieve the mining informations. """ if PyFunceble.CONFIGURATION["mining"]: # The mining is activated. if "mined" not in PyFunceble.INTERN: PyFunceble.INTERN["mined"] = {} if PyFunceble.path.isfile(self.file...
def _backup(self): """ Backup the mined informations. """ if PyFunceble.CONFIGURATION["mining"]: # The mining is activated. # We backup our mined informations. Dict(PyFunceble.INTERN["mined"]).to_json(self.file)
def _add(self, to_add): """ Add the currently mined information to the mined "database". :param to_add: The element to add. :type to_add: dict """ if PyFunceble.CONFIGURATION["mining"]: # The mining is activated. if PyFunceble.INTERN["fi...
def remove(self): """ Remove the currently tested element from the mining data. """ if PyFunceble.CONFIGURATION["mining"]: # The mining is activated. if PyFunceble.INTERN["file_to_test"] in PyFunceble.INTERN["mined"]: # The currently test...
def list_of_mined(cls): """ Provide the list of mined so they can be added to the list queue. :return: The list of mined domains or URL. :rtype: list """ # We initiate a variable which will return the result. result = [] if PyFunceble.CONFIGURAT...
def process(self): # pragma: no cover """ Process the logic and structuration of the mining database. """ if PyFunceble.CONFIGURATION["mining"]: # The mining is activated. # We load the mining logic. mined = self.mine() if mined: ...
def _get_content(cls, file): """ Get and return the content of the given log file. :param file: The file we have to get the content from. :type file: str :return The content of the given file. :rtype: dict """ if PyFunceble.path.isfile(file): ...
def _write_content(cls, content, file): """ Write the content into the given file. :param content: The dict to write. :type content: dict :param file: The file to write. :type file: str """ if not PyFunceble.CONFIGURATION["no_files"]: if not...
def whois(self, record): """ Logs the WHOIS record if needed. :param record: The record to log. :type record: str """ if PyFunceble.CONFIGURATION["debug"] and PyFunceble.CONFIGURATION["logs"]: # The debug and the logs subsystem are activated. if...
def expiration_date(self, extracted): """ Logs the extracted expiration date. :param extracted: The extracted expiration date (from WHOIS record). :type extracted: str """ if PyFunceble.CONFIGURATION["logs"]: # The logs subsystem is activated. i...
def referer_not_found(self, extension): """ Logs the case that the referer was not found. :param extension: The extension of the domain we are testing. :type extension: str """ if PyFunceble.CONFIGURATION["logs"]: # The logs subsystem is activated. ...
def _before_header(self): """ Print informations about PyFunceble and the date of generation of a file into a given path, if doesn't exist. """ if ( not PyFunceble.CONFIGURATION["no_files"] and self.output and not PyFunceble.path.isfile(self.o...