~leonardr/launchpadlib/use-1.0

« back to all changes in this revision

Viewing changes to src/launchpadlib/launchpad.py

  • Committer: Leonard Richardson
  • Date: 2009-12-17 20:19:07 UTC
  • mfrom: (77.1.2 test-failures)
  • Revision ID: leonard.richardson@canonical.com-20091217201907-2os9juhrv9ht9l64
[r=gary] Fix some test failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
177
177
        cls, consumer_name, service_root=uris.STAGING_SERVICE_ROOT,
178
178
        launchpadlib_dir=None, timeout=None, proxy_info=None):
179
179
        """Get access to Launchpad without providing any credentials."""
180
 
        service_root, service_root_dir, cache_path = cls._get_paths(
181
 
            service_root, launchpadlib_dir)
 
180
        (service_root, launchpadlib_dir, cache_path,
 
181
         service_root_dir) = cls._get_paths(service_root, launchpadlib_dir)
182
182
        token = AnonymousAccessToken()
183
183
        credentials = Credentials(consumer_name, access_token=token)
184
 
        return cls(credentials, service_root, cache_path, timeout, proxy_info)
 
184
        return cls(credentials, service_root=service_root, cache=cache_path,
 
185
                   timeout=timeout, proxy_info=proxy_info)
185
186
 
186
187
    @classmethod
187
188
    def login_with(cls, consumer_name,
224
225
        :rtype: `Launchpad`
225
226
 
226
227
        """
227
 
        service_root, service_root_dir, cache_path = cls._get_paths(
228
 
            service_root, launchpadlib_dir)
 
228
        (service_root, launchpadlib_dir, cache_path,
 
229
         service_root_dir) = cls._get_paths(service_root, launchpadlib_dir)
229
230
        credentials_path = os.path.join(service_root_dir, 'credentials')
230
231
        if not os.path.exists(credentials_path):
231
232
            os.makedirs(credentials_path)
261
262
        :param service_root: The service root the user wants to
262
263
            connect to. This may be an alias (which will be
263
264
            dereferenced to a URL and returned) or a URL (which will
264
 
            be returned as is).
265
 
        :param launchpadlib_dir: The user's base launchpadlib directory,
266
 
            if known.
267
 
        :return: A 3-tuple: (service_root_uri, cache_dir, service_root_dir)
 
265
            be returned as is).  :param launchpadlib_dir: The user's
 
266
            base launchpadlib directory, if known. This may be
 
267
            modified, expanded, or determined from the environment if
 
268
            missing. A definitive value will be returned.
 
269
 
 
270
        :return: A 4-tuple:
 
271
            (service_root_uri, launchpadlib_dir, cache_dir, service_root_dir)
268
272
        """
269
273
        if launchpadlib_dir is None:
270
274
            home_dir = os.environ['HOME']
282
286
        cache_path = os.path.join(service_root_dir, 'cache')
283
287
        if not os.path.exists(cache_path):
284
288
            os.makedirs(cache_path)
285
 
        return (service_root, cache_path, service_root_dir)
 
289
        return (service_root, launchpadlib_dir, cache_path, service_root_dir)