當前位置: 首頁>>代碼示例>>Python>>正文


Python repository.Repository類代碼示例

本文整理匯總了Python中repository.Repository的典型用法代碼示例。如果您正苦於以下問題:Python Repository類的具體用法?Python Repository怎麽用?Python Repository使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Repository類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_repository_add_search_keyword_success

    def test_repository_add_search_keyword_success(self):
        repo = Repository(repo_name)
        doc = test_doc(repo)

        result = repo.search_keywords('jungle')

        self.assertEqual(len(result), 1)
開發者ID:scottgw,項目名稱:paperless,代碼行數:7,代碼來源:repository_test.py

示例2: cmd_checkout

 def cmd_checkout(branch):
     b = Branch()
     b.switch_branch(branch)
     repo = Repository()
     pre_entries = dict(repo.index.entries)  
     repo.rebuild_index_from_commit(repo.branch.head_commit)
     repo.rebuild_working_tree(pre_entries)
開發者ID:Oloshka,項目名稱:git-in-python,代碼行數:7,代碼來源:command.py

示例3: __init__

    def __init__(self, filename=None):
        if not filename:
            raise FileRepositoryException("Please set a filename")

        self._filename = filename
        Repository.__init__(self)
        self._load()
開發者ID:leyyin,項目名稱:university,代碼行數:7,代碼來源:filerepository.py

示例4: test_repository_add_remove_has_not

    def test_repository_add_remove_has_not(self):
        repo = Repository(repo_name)
        doc = test_doc(repo)

        repo.remove_document(doc)

        self.assertFalse(repo.has_document_uuid(doc.uuid))
開發者ID:scottgw,項目名稱:paperless,代碼行數:7,代碼來源:repository_test.py

示例5: app_setup

def app_setup(app):
    app.config['CELERY_ACCEPT_CONTENT'] = ['json']
    app.config['CELERY_TASK_SERIALIZER'] = 'json'
    app.config['CELERY_RESULT_SERIALIZER'] = 'json'
    app.config['CELERY_BROKER_URL'] = 'redis://localhost:6379/2'
    app.config['CELERY_BACKEND'] = 'redis://localhost:6379/3'
    app.config['CELERY_QUEUES'] = (
        Queue('transplant', Exchange('transplant'), routing_key='transplant'),
    )

    app.src_dir = tempfile.mkdtemp(dir=test_temp_dir)
    app.dst_dir = tempfile.mkdtemp(dir=test_temp_dir)
    app.config['TRANSPLANT_WORKDIR'] = tempfile.mkdtemp(dir=test_temp_dir)
    app.config['TRANSPLANT_REPOSITORIES'] = [{
        'name': 'test-src',
        'path': app.src_dir
    }, {
        'name': 'test-dst',
        'path': app.dst_dir
    }]

    app.src = Repository.init(app.src_dir)
    app.dst = Repository.init(app.dst_dir)

    _set_test_file_content(app.src_dir, "Hello World!\n")
    app.src.commit("Initial commit", addremove=True, user="Test User")
    app.dst.pull(app.src_dir, update=True)
開發者ID:laggyluke,項目名稱:build-transplant,代碼行數:27,代碼來源:new_tst_transplant.py

示例6: BaseHaskiAction

class BaseHaskiAction(object):
    """This class is the abstract base class for Haski tasks.
    """
    __metaclass__ = ABCMeta

    def __init__(self):
        self._repository = Repository()

    @abstractmethod
    def __call__(self, namespace):
        """This method is invoked by argparse and should do the actuall work.
        By default, it is abstract and does nothing, so it forces you to
        implement it.
        """
        pass

    def get_commit(self, namespace):
        """This function gets the commit wanted commit on which an action is to
        be performed.
        """
        commit = self._repository.get_commit(namespace.revision)
        return commit

    def get_repository_location(self):
        """Returns the directory where this repository is located.
        """
        return self._repository.get_path()
開發者ID:brahle,項目名稱:eval2,代碼行數:27,代碼來源:baseaction.py

示例7: test_status_untracked_files

 def test_status_untracked_files(self):
     path, content = ('1.txt', '1\n')
     write_to_file(path, content)
     repo = Repository()
     untracked_files = repo.get_untracked_files()
     self.assertEqual(untracked_files, ['1.txt'])
     Command.cmd_status()
開發者ID:Oloshka,項目名稱:git-in-python,代碼行數:7,代碼來源:test_status.py

示例8: validate_name

    def validate_name(self, min_length, model, parameter):
        if len(parameter) < min_length:
            message = "The name should be at least {} symbols"
            raise Exception(message.format(min_length))

        repository = Repository(self.__db_name)
        if repository.is_name_used(model, parameter):
            raise Exception("This name is already taken")
開發者ID:EmanuelaMollova,項目名稱:Zoo,代碼行數:8,代碼來源:validator.py

示例9: test_reset_default

 def test_reset_default(self):
     Command.cmd_reset(self.first_commit, is_soft=False, is_hard=False)
     self.assertEqual(Branch().head_commit, self.first_commit)
     repo = Repository()
     uncommitted_files = repo.get_uncommitted_files()
     unstaged_files = repo.get_unstaged_files()
     self.assertFalse(uncommitted_files['modified'])
     self.assertIn(self.path, unstaged_files['modified'])
開發者ID:Oloshka,項目名稱:git-in-python,代碼行數:8,代碼來源:test_reset.py

示例10: TwitterDataProcess

class TwitterDataProcess():
    def __init__(self, topics, file_name):
        self.file_name = file_name
        self.topics = topics
        self.tweets = []
        self.repository = Repository()
        self.process_tweets()

    @staticmethod
    def compact_tweet_text(tweet_text):
        return tweet_text.replace('\n', ' ').replace('\r', '').lower()

    @staticmethod
    def to_dictionary(coordinate):
        keys = ["Lat", "Lng"]
        return dict(zip(keys, coordinate))

    def check_key_words(self, topic_key, tweet_text):
        if re.search(topic_key, tweet_text):
            for word in self.topics.get(topic_key):
                if re.search(word, tweet_text):
                    return True
        return False

    def process_tweets(self):
        self.tweets = []
        with open(self.file_name, "r") as tweets_file:
            for line in tweets_file:
                tweet = dict()
                tweet_valid = False
                try:
                    if line.strip() != '':
                        raw_tweet = json.loads(line)
                        text = TwitterDataProcess.compact_tweet_text(raw_tweet['text'])
                        for topic_key in self.topics:
                            if self.check_key_words(topic_key, text):
                                tweet_valid = True
                                tweet[topic_key] = True
                            else:
                                tweet[topic_key] = False
                        if tweet_valid:
                            tweet['text'] = text
                            tweet['lang'] = raw_tweet['lang']
                            tweet['city'] = raw_tweet['place']['name'] if raw_tweet['place'] is not None else None
                            if raw_tweet['geo'] is None:
                                tweet['coordinates'] = False
                            else:
                                tweet['coordinates'] = True
                                tweet.update(TwitterDataProcess.to_dictionary(raw_tweet['geo']['coordinates']))
                                self.tweets.append(tweet)
                            if len(self.tweets) > 1000:
                                self.repository.save_many(self.tweets)
                                self.tweets = []

                except Exception as e:
                    print(str(e))
                    continue
        self.repository.save_many(self.tweets)
開發者ID:yazquez,項目名稱:TwitterActivityAnalysis.python,代碼行數:58,代碼來源:data_process.py

示例11: add_endpoint

def add_endpoint(my_request):

    if not my_request.pmh_url:
        return None

    endpoint_with_this_id = Endpoint.query.filter(Endpoint.repo_request_id==my_request.id).first()
    if endpoint_with_this_id:
        print u"one already matches {}".format(my_request.id)
        return None

    raw_endpoint = my_request.pmh_url
    clean_endpoint = raw_endpoint.strip()
    clean_endpoint = clean_endpoint.strip("?")
    clean_endpoint = re.sub(u"\?verb=.*$", "", clean_endpoint, re.IGNORECASE)
    print u"raw endpoint is {}, clean endpoint is {}".format(raw_endpoint, clean_endpoint)

    matching_endpoint = Endpoint()
    matching_endpoint.pmh_url = clean_endpoint

    repo_matches = my_request.matching_repositories()
    if repo_matches:
        matching_repo = repo_matches[0]
        print u"yay! for {} {} matches repository {}".format(
            my_request.institution_name, my_request.repo_name, matching_repo)
    else:
        print u"no matching repository for {}: {}".format(
            my_request.institution_name, my_request.repo_name)
        matching_repo = Repository()

    # overwrite stuff with request
    matching_repo.institution_name = my_request.institution_name
    matching_repo.repository_name = my_request.repo_name
    matching_repo.home_page = my_request.repo_home_page
    matching_endpoint.repo_unique_id = matching_repo.id
    matching_endpoint.email = my_request.email
    matching_endpoint.repo_request_id = my_request.id
    matching_endpoint.ready_to_run = True
    matching_endpoint.set_identify_and_initial_query()

    db.session.merge(matching_endpoint)
    db.session.merge(matching_repo)
    print u"added {} {}".format(matching_endpoint, matching_repo)
    print u"see at url http://unpaywall.org/sources/repository/{}".format(matching_endpoint.id)
    safe_commit(db)
    print "saved"

    print "now sending email"
    # get the endpoint again, so it gets with all the meta info etc
    matching_endpoint = Endpoint.query.get(matching_endpoint.id)
    matching_endpoint.contacted_text = "automated welcome email"
    matching_endpoint.contacted = datetime.datetime.utcnow().isoformat()
    safe_commit(db)
    send_announcement_email(matching_endpoint)

    print "email sent"

    return matching_endpoint
開發者ID:Impactstory,項目名稱:sherlockoa,代碼行數:57,代碼來源:put_repo_requests_in_db.py

示例12: __init__

 def __init__(self, repoid, repoConfig, maxFileLength=1024*1024*1024*2,
              retryTime=3, socketTimeout=5):
     Repository.__init__(self, repoid)
     self.repoConfig = repoConfig
     self.cachedir = None
     self.expireTime = None
     self.enabled = bool(repoConfig.enabled)
     self.maxFileLength = maxFileLength
     self.retryTime = retryTime
     self.socketTimeout = socketTimeout
開發者ID:luckylecher,項目名稱:cpp,代碼行數:10,代碼來源:yum_repository.py

示例13: main

def main(argv):

    config_file = None
    read_only = False
    verbose = False

    try:
        # -h (optional), -c (mandatory, hence 'c:'), -r (optional)
        opts, args = getopt.getopt(argv,"hc:rv",[])
    except getopt.GetoptError:
        print 'repository.py [-h] [-r] [-v] -c <cfgfile>'
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print 'repository.py [-h] [-r] [-v] -c <cfgfile>'
            sys.exit(0)
        elif opt in ("-c", "--cfgfile"):
            config_file = arg
        elif opt == '-r':
            read_only = True
        elif opt == '-v':
            verbose = True

    if config_file is None:
        print 'repository.py [-h] [-r] [-v] -c <cfgfile>'
        sys.exit(2)

    if verbose: print 'Using cfg file:', config_file
    repository = Repository(config_file, verbose)
    
    config = ConfigParser.RawConfigParser()
    config.read(config_file)

    sensor_names = config.get("sensors", "names").strip().split(',')
    if verbose: print 'Sensor names:', sensor_names

    sensors = []

    for name in sensor_names:
        if verbose: print 'Adding sensor:', name
        sensors.append(Sensor(name, config_file))
    
    for sensor in sensors:
        if verbose: print 'Reading sensor', sensor.sensor_id

        readings = sensor.get_readings()
        if readings is not None:
            if read_only:
                s=json.dumps(readings, sort_keys=True, indent=4, separators=(',', ': '))
                print s
            else:
                repository.save_readings(readings)

    print 'Done'
開發者ID:halingo,項目名稱:1wire-logger,代碼行數:55,代碼來源:logger.py

示例14: repositories

	def repositories(self):
		_repos = self.db.query("SELECT id FROM repositories WHERE distro_id = %s", self.id)

		repos = []
		for repo in _repos:
			repo = Repository(self.pakfire, repo.id)
			repo._distro = self

			repos.append(repo)

		return sorted(repos)
開發者ID:,項目名稱:,代碼行數:11,代碼來源:

示例15: get_repo

	def get_repo(self, name):
		repo = self.db.get("SELECT id FROM repositories WHERE distro_id = %s AND name = %s",
			self.id, name)

		if not repo:
			return

		repo = Repository(self.pakfire, repo.id)
		repo._distro = self

		return repo
開發者ID:,項目名稱:,代碼行數:11,代碼來源:


注:本文中的repository.Repository類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。