Example #1
0
 def test_get_data_no_json(self):
     with pytest.raises(ValueError):
         Contributor.get_partner_data(
             '30709653543',
             url=
             "https://www.google.com.ar/?gfe_rd=cr&ei=uWRqWLaUNYyTwASCjLPABQ&gws_rd=ssl#q="
         )
Example #2
0
 def test_set_partner_data_invalid_cuit(self):
     contributor = Contributor()
     contributor.set_partner_data('307120979531')
     assert contributor.document_number == '307120979531'
     assert contributor.name == None
     assert contributor.postal_code == None
     assert contributor.street == None
     assert contributor.state_code == None
Example #3
0
 def test_set_partner_data(self):
     contributor = Contributor()
     contributor.set_partner_data('30712097953')
     assert contributor.document_number == '30712097953'
     assert contributor.name == 'OPENPYME SRL'
     assert contributor.postal_code == '1425'
     assert contributor.street == 'BILLINGHURST 1964'
     assert contributor.state_code == 0
Example #4
0
    def add_contributor(self,
                        name,
                        roles,
                        aliases=None,
                        lc=None,
                        viaf=None,
                        **kwargs):
        """Assign a contributor to this Edition."""
        _db = Session.object_session(self)
        if isinstance(roles, basestring):
            roles = [roles]

        # First find or create the Contributor.
        if isinstance(name, Contributor):
            contributor = name
        else:
            contributor, was_new = Contributor.lookup(_db, name, lc, viaf,
                                                      aliases)
            if isinstance(contributor, list):
                # Contributor was looked up/created by name,
                # which returns a list.
                contributor = contributor[0]

        # Then add their Contributions.
        for role in roles:
            contribution, was_new = get_one_or_create(_db,
                                                      Contribution,
                                                      edition=self,
                                                      contributor=contributor,
                                                      role=role)
        return contributor
Example #5
0
 def collect_commits(self, top):
     contributors_json = self._get_contributors(top)
     contributors = [
         Contributor(contributor['login'])
         for contributor in contributors_json[:top]
     ]
     for i, contributor in enumerate(contributors):
         commits_json = self._get_commits_by_author(contributor.name)
         contributor.commits = [commit['sha'] for commit in commits_json]
         print(f'collecting commits: {(i + 1) * 100 // top}%')
     return contributors
Example #6
0
    def get_contributor(self):
        """Return contributor
        :returns: TODO

        """
        nickname = self.nickname.get_text()
        name = self.name.get_text()
        url = self.url.get_text()
        avatar_url = self.avatar_url.get_text()
        role = get_selected_in_combo(self.role)
        contributor = Contributor(nickname, name, role, avatar_url, url)
        return contributor
Example #7
0
 def read_file(self, filename):
     general = self.read_section('project-info', filename)
     self.parse_general(general)
     description = self.read_section('description', filename)
     self.boxDescription.set_content(description)
     prerequisites = self.read_section('prerequisites', filename)
     self.boxDependencies.set_content(prerequisites)
     installing = self.read_section('installing', filename)
     self.boxInstalling.set_content(installing)
     using = self.read_section('using', filename)
     self.boxUsing.set_content(using)
     contributing = self.read_section('contributing', filename)
     self.boxContributing.set_content(contributing)
     intro_contributors = self.read_section('contributors', filename)
     self.boxContributors.set_content(intro_contributors)
     contributors = self.read_section('table-contributors', filename)
     soup = BeautifulSoup(contributors, 'html.parser')
     for table in soup.findAll('table'):
         if table['id'] == 'contributors':
             columns = table.findAll('td')
             rows = table.findAll('tr')
             ncolumns = len(columns)
             nrows = len(rows)
             if ncolumns > 0 and nrows > 0 and ncolumns % nrows == 0:
                 ncontributors = int(ncolumns / nrows)
             pcontributors = {}
             for row in rows:
                 columns = row.findAll('td')
                 for column in columns:
                     if column['id'] and column['id'] not in pcontributors:
                         pcontributors[column['id']] = Contributor(
                             column['id'])
                     if row['id'] == 'info_avatar':
                         pcontributors[column['id']].set_url(
                             column.a['href'])
                         pcontributors[column['id']].set_avatar_url(
                             column.a.img['src'])
                     elif row['id'] == 'info_name':
                         pcontributors[column['id']].set_name(
                             column.a.get_text().strip())
                     elif row['id'] == 'info_commit':
                         pcontributors[column['id']].set_role(
                             column.a.span.get_text())
             self.boxContributors.set_contributors(pcontributors.values())
             break
Example #8
0
    def from_pydriller_method(cls, path: str,
                              method: pydriller.domain.commit.Method,
                              n_commits: int,
                              developers: Collection[Developer],
                              project: Project):
        # /src/test/java/package/file.java -> .src.test.java.package.file.java
        package = path.replace('/', '.')
        # .src.test.java.package.file.java -> src.test.java.package.file.class
        package = package.lstrip('.')
        # src.test.java.package.file.class -> package.file.java
        package = package.split('.', maxsplit=3)[-1]
        # package.file.class -> package
        package = package.rsplit('.', maxsplit=2)[0]

        contributors = {
            Contributor.from_pydriller_method(c, project)
            for c in developers
        }

        new_method = cls(package, method.name, method.nloc, method.complexity,
                         n_commits, contributors)

        return new_method
Example #9
0
 def get_values(banks_list):
     '''
     :param banks_list: Lista de bancos.
     :return: Lista de diccionarios con los valores de cada banco
     '''
     
     values = []
     for bank_list in banks_list:
         
         bank_values = {}
         
         if bank_list:    
             
             #Validamos el cuit del banco para comprobar existencia
             if Contributor.is_valid_cuit(bank_list[0]):
         
                 bank_values['cuit'] = bank_list[0]
                 bank_values['code'] = bank_list[1]
                 bank_values['name'] = unidecode(bank_list[2])
                 values.append(bank_values)
         
     return values
             
         
Example #10
0
 def test_valid_cuit(self):
     cuit = '30709653543'
     assert Contributor.is_valid_cuit(cuit)
     cuit = 30709653543
     assert Contributor.is_valid_cuit(cuit)
Example #11
0
def load_contributors_files(filename):
    with open(filename, 'r') as fin:
        return [
            Contributor(name, files=set(files))
            for name, files in json.load(fin).items()
        ]
Example #12
0
 def test_cuit_with_dash(self):
     cuit = '30-70965354-3'
     assert Contributor.is_valid_cuit(cuit) == 0
Example #13
0
 def test_11_digits_no_int(self):
     cuit = 'A1234567891'
     assert Contributor.is_valid_cuit(cuit) == 0
Example #14
0
 def test_cuit_without_11_digits(self):
     cuit = '3070965354'
     assert Contributor.is_valid_cuit(cuit) == 0
     cuit = 3070965354
     assert Contributor.is_valid_cuit(cuit) == 0
Example #15
0
 def test_invalid_cuit(self):
     cuit = '30709653542'
     assert Contributor.is_valid_cuit(cuit) == 0
     cuit = 30709653542
     assert Contributor.is_valid_cuit(cuit) == 0
Example #16
0
 def __init__(self,nickname,email,phone,name,eid):
     Contributor.__init__(self,nickname,email,phone,name,eid)
Example #17
0
 def test_get_partner_data(self):
     Contributor.get_partner_data('30709653543')
Example #18
0
 def test_get_data_invalid_url(self):
     with pytest.raises(ValueError):
         Contributor.get_partner_data('30709653543', url="invalidUrl")
Example #19
0
            random_number = randint(0, len(contributors) - 1)

    def currency_round_up(self, num, places):
        return math.ceil(num * 10**places) / 10**places

    def currency_round_down(self, num, places):
        return math.floor(num * 10**places) / 10**places

    def digits_after_decimal(self, cont):
        s = str(cont)
        if not '.' in s:
            return 0
        return len(s) - s.index('.') - 1


#Testing
num = 7
bill = Bill(341.37)

for x in range(num):
    cont = Contributor()
    bill.add_contributor(cont)

bill.even_split()

for key in bill.contributions:
    print(
        '{contributor} has to pay the following bills: {bills}. They are responsible for the following: {amount}'
        .format(contributor=key,
                bills=key.bills,
                amount=bill.contributions[key]))
Example #20
0
def load_contributors_commits(filename):
    with open(filename, 'r') as fin:
        return [
            Contributor(name, commits)
            for name, commits in json.load(fin).items()
        ]