~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/charmstore.py

  • Committer: Benji York
  • Date: 2013-11-18 20:38:47 UTC
  • mto: This revision was merged to the branch mainline in revision 465.
  • Revision ID: benji@benjiyork.com-20131118203847-2mfs1w7b8aqy64mr
checkpoint

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
 
7
7
from datetime import timedelta
8
 
import os
 
8
 
 
9
 
9
10
from requests import (
10
11
    Request,
11
12
    Session,
109
110
        return sum(downloads for date, downloads in counts)
110
111
 
111
112
 
112
 
class LocalCharmStore(CharmStore):
113
 
 
114
 
    def __init__(self):
115
 
        self.charm_data = {}
116
 
 
117
 
    def set_charm_data(self, charm_data):
118
 
        self.charm_data = {}
119
 
        for charm in charm_data:
120
 
            self.charm_data[charm['name']] = charm
121
 
 
122
 
    def get_charms_info(self, addresses):
123
 
        info = {}
124
 
        for addr in addresses:
125
 
            charm_name = addr.split(os.sep)[-1]
126
 
            if charm_name in self.charm_data:
127
 
                info[addr] = dict(
128
 
                    revision=0,
129
 
                    digest=self.charm_data[charm_name]['commit'])
130
 
        return info
131
 
 
132
 
    def get_download_counts(self, charm, start=None, end=None):
133
 
        return []
134
 
 
135
 
 
136
113
def get_store_charm_info(store, charms, num_revisions=10):
137
114
    """Get information from the store about the charms.
138
115