Ejemplo n.º 1
0
    def __init__(self, parent=None):

        super(Tuto, self).__init__(parent)

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.parent = parent
        self.resource_dir, self.DATA_PATH = functions.getRightDirs()

        if parent is None:
            self.test = True
        else:
            self.test = False

        self.setModal(True)

        # Get the text of the slides from config files
        with open(os.path.join(self.resource_dir, 'config/tuto.txt'),
                  'r',
                  encoding='utf-8') as f:
            content = f.read()
            self.list_slides = content.split('--')

        # Index of the slide
        self.index = 0

        self.initUI()
        self.defineSlots()
Ejemplo n.º 2
0
    def __init__(self, parent=None):

        super(WizardDelJournal, self).__init__(parent)

        self.setModal(True)

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.parent = parent

        self.resource_dir, self.DATA_PATH = functions.getRightDirs()

        if parent is None:
            self.l = MyLog("activity.log")

            # Dummy file for saving if testing
            self.options = QtCore.QSettings("debug/options.ini",
                                            QtCore.QSettings.IniFormat)

            self.test = True
        else:
            self.l = self.parent.l
            self.options = self.parent.options
            self.test = False

        # Store the checkboxes of the window
        self.check_journals = []

        self.initUI()
        self.defineSlots()
Ejemplo n.º 3
0
    def __init__(self, parent=None):

        super(AdvancedSearch, self).__init__(parent)

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.parent = parent

        self.resource_dir, DATA_PATH = functions.getRightDirs()

        # Condition to use a specific logger if
        # module started in standalone
        if parent is None:
            self.logger = MyLog("activity.log")
            self.test = True
        else:
            self.logger = self.parent.l
            self.test = False

        self.options = QtCore.QSettings(DATA_PATH + "/config/searches.ini",
                                        QtCore.QSettings.IniFormat)

        # List to store the lineEdit, with the value of
        # the search fields
        self.fields_list = []

        self.initUI()
        self.defineSlots()
        self.restoreSettings()
Ejemplo n.º 4
0
def getCompanies(user: bool = False) -> list:
    """
    Get a list of all the companies. Will return a list of publishers, without
    .ini at the end. If user is true, returns companies on the user's side
    """

    resource_dir, DATA_PATH = fct.getRightDirs()

    cb_companies = []

    # List companies on the program side
    for company in os.listdir(os.path.join(resource_dir, 'journals')):
        company = company.split('.')[0]
        cb_companies.append(company)

    if not user:
        return list(set(cb_companies))

    user_companies = []

    # List companies on the user side
    for company in os.listdir(os.path.join(DATA_PATH, 'journals')):
        company = company.split('.')[0]
        user_companies.append(company)

    return list(set(cb_companies + user_companies))
Ejemplo n.º 5
0
    def __init__(self, parent=None):

        super(Signing, self).__init__(parent)

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.parent = parent

        self.resource_dir, self.DATA_PATH = functions.getRightDirs()

        if parent is None:
            self.logger = MyLog("activity.log")
            self.test = True
        else:
            self.logger = self.parent.l
            self.test = False

        # Attribute to check if the login was valid
        self.validated = False

        self.setModal(True)

        self.initUI()
        self.defineSlots()
        self.getCaptcha()
Ejemplo n.º 6
0
    def getStopWords(self):

        """Method to get english stop words
        + a list of personnal stop words"""

        my_additional_stop_words = []

        resource_dir, _ = functions.getRightDirs()

        with open(os.path.join(resource_dir, 'config/stop_words.txt'), 'r',
                  encoding='utf-8') as config:
            for word in config.readlines():
                my_additional_stop_words.append(word.rstrip())

        self.stop_words = text.ENGLISH_STOP_WORDS.union(my_additional_stop_words)
Ejemplo n.º 7
0
def reject(entry_title):
    """Function called by a Worker object to filter crappy entries.
    It is meant to reject articles like corrigendum, erratum, etc"""

    resource_dir, DATA_PATH = fct.getRightDirs()

    # resource_dir = os.path.dirname(os.path.dirname(sys.executable))
    # Load the regex stored in a config file, as filters
    with open(os.path.join(resource_dir, 'config/regex.txt'),
              'r',
              encoding='utf-8') as filters_file:
        filters = filters_file.read().splitlines()

    # Try to match the filters against the title entry
    responses = [bool(re.search(regex, entry_title)) for regex in filters]

    # If one filter matched, reject the entry
    if True in responses:
        return True
    else:
        return False
Ejemplo n.º 8
0
    def __init__(self, title, link, graphical=None, parent=None):

        super(MyTwit, self).__init__(parent)

        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.parent = parent

        # Remove html tags from the title
        self.title = removeHtml(title)

        self.link = link
        self.graphical = graphical

        self.resource_dir, self.DATA_PATH = functions.getRightDirs()

        if parent is None:
            self.l = MyLog("activity.log")
        else:
            self.l = self.parent.l

        self.CONSUMER_KEY = 'IaTVXKtZ7uBjzcVWzsVmMYKtP'
        self.CONSUMER_SECRET = '8hsz0Zj3CupFfvJMAhpG3UjMLs7HZjGywRsjRJI8IcjIA4NrEk'

        self.MY_TWITTER_CREDS = self.DATA_PATH + '/config/twitter_credentials'

        self.initUI()
        self.defineSlots()

        # If no credentials, try to get them
        if not os.path.exists(self.MY_TWITTER_CREDS):
            authentified = self.openAuthPage()

            # No credentials obtained, exit
            if not authentified:
                return

        self.setTweetText()
        self.show()
Ejemplo n.º 9
0
def getJournals(company, user=False):
    """Function to get the informations about all the journals of
    a company. Returns the names, the URLs, the abbreviations, and also
    a boolean to set the download of the graphical abstracts. If for a
    journal this boolean is False, the Worker object will not try to dl
    the picture. If user is true, returns only the journals on the user's
    side"""

    names = []
    abb = []
    urls = []
    cares_image = []

    resource_dir, DATA_PATH = fct.getRightDirs()

    if not user:
        with open(os.path.join(resource_dir, 'journals',
                               '{}.ini'.format(company)),
                  'r',
                  encoding='utf-8') as config:
            for line in config:
                names.append(line.split(" : ")[0])
                abb.append(line.split(" : ")[1].rstrip())
                urls.append(line.split(" : ")[2].rstrip())

                # Get a bool: care about the image when refreshing
                try:
                    care = line.split(" : ")[3].rstrip()
                    if care == "False":
                        cares_image.append(False)
                    else:
                        cares_image.append(True)
                except IndexError:
                    cares_image.append(True)

    # If the user didn't add a journal from this company, the file
    # won't exist, so exit
    if not os.path.exists(
            os.path.join(DATA_PATH, 'journals', '{}.ini'.format(company))):
        return names, abb, urls, cares_image

    with open(os.path.join(DATA_PATH, 'journals', '{}.ini'.format(company)),
              'r',
              encoding='utf-8') as config:

        for line in config:
            url = line.split(" : ")[2].rstrip()

            if url not in urls:
                names.append(line.split(" : ")[0])
                abb.append(line.split(" : ")[1].rstrip())
                urls.append(url)

                # Get a bool: care about the image when refreshing
                try:
                    care = line.split(" : ")[3].rstrip()
                    if care == "False":
                        cares_image.append(False)
                    else:
                        cares_image.append(True)
                except IndexError:
                    cares_image.append(True)

    return names, abb, urls, cares_image