Python app.db.Integer() Examples

The following are 2 code examples of app.db.Integer(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module app.db , or try the search function .
Example #1
Source File: cran_package.py    From depsy with MIT License 6 votes vote down vote up
def set_github_repo_ids_from_cran_name(self):
        q = db.session.query(GithubRepo.login, GithubRepo.repo_name)
        q = q.filter(GithubRepo.language == 'r')
        q = q.filter(GithubRepo.login != 'cran')  # these are just mirrors.
        q = q.filter(GithubRepo.bucket.contains({"cran_descr_file_name": self.project_name}))
        q = q.order_by(GithubRepo.api_raw['stargazers_count'].cast(db.Integer).desc())

        start = time()
        row = q.first()
        print "Github repo query took {}".format(elapsed(start, 4))

        if row is None:
            return None

        else:
            print "Setting a new github repo for {}: {}/{}".format(
                self,
                row[0],
                row[1]
            )
            self.github_owner = row[0]
            self.github_repo_name = row[1]
            self.bucket["matched_from_github_metadata"] = True 
Example #2
Source File: pypi_package.py    From depsy with MIT License 4 votes vote down vote up
def set_github_repo(self):
        try:
            urls_str = self.api_raw["info"]["home_page"]
        except KeyError:
            return False

        # People put all kinds of lists in this field. So we're splitting on
        # newlines, commas, and spaces. Won't get everything, but will
        # get most.
        if not urls_str:
            return
        urls = re.compile(r",*\s*\n*").split(urls_str)

        for url in urls:
            login, repo_name = github_api.login_and_repo_name_from_url(url)
            if login and repo_name:
                self.github_repo_name = repo_name
                self.github_owner = login

                # there may be more than one github url. if so, too bad,
                # we're just picking the first one.
                break

        print u"successfully set a github ID for {name}: {login}/{repo_name}.".format(
            name=self.project_name,
            login=self.github_owner,
            repo_name=self.github_repo_name
        )

    # not currently used?
    # def set_github_repo_ids_from_setuppy_name(self):
    #     q = db.session.query(GithubRepo.login, GithubRepo.repo_name)
    #     q = q.filter(GithubRepo.bucket.contains({"setup_py_name": self.project_name}))
    #     q = q.order_by(GithubRepo.api_raw['stargazers_count'].cast(db.Integer).desc())
    #
    #     start = time()
    #     row = q.first()
    #     print "Github repo query took {}".format(elapsed(start, 4))
    #
    #     if row is None:
    #         return None
    #
    #     else:
    #         print "Setting a new github repo for {}: {}/{}".format(
    #             self,
    #             row[0],
    #             row[1]
    #         )
    #         self.github_owner = row[0]
    #         self.github_repo_name = row[1]
    #         self.bucket["matched_from_github_metadata"] = True