Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating base to start work on vimeo wrapper
- Loading branch information
Showing
4 changed files
with
15 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,2 @@ | ||
#!/usr/bin/python | ||
|
||
# Copyright (c) 2008 Patrick Altman http://paltman.com | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a | ||
# copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, dis- | ||
# tribute, sublicense, and/or sell copies of the Software, and to permit | ||
# persons to whom the Software is furnished to do so, subject to the fol- | ||
# lowing conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- | ||
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | ||
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
# IN THE SOFTWARE. | ||
import ConfigParser | ||
import os | ||
|
||
|
||
SystemConfigPath = '/etc/pyvimeo.cfg' | ||
UserConfigPath = '~/.pyvimeo' | ||
|
||
class Config(ConfigParser.SafeConfigParser): | ||
def __init__(self, path=None, fp=None): | ||
ConfigParser.SafeConfigParser.__init__(self) | ||
|
||
if path: | ||
self.read(path) | ||
elif fp: | ||
self.readfp(fp) | ||
else: | ||
self.read([SystemConfigPath, os.path.expanduser(UserConfigPath)]) | ||
|
||
def save_option(self, path, section, option, value): | ||
""" | ||
Write the specified Section.Option to the config file specified by path. | ||
Replace any previous value. If the path doesn't exist, create it. | ||
Also add the option the the in-memory config. | ||
Borrowed this code from the boto project. :-) Thanks, Mitch. | ||
""" | ||
config = ConfigParser.SafeConfigParser() | ||
config.read(path) | ||
if not config.has_section(section): | ||
config.add_section(section) | ||
config.set(section, option, value) | ||
fp = open(path, 'w') | ||
config.write(fp) | ||
fp.close() | ||
if not self.has_section(section): | ||
self.add_section(section) | ||
self.set(section, option, value) | ||
|
||
def save_user_option(self, section, option, value): | ||
self.save_option(os.path.expanduser(UserConfigPath), section, option, value) | ||
|
||
def save_system_option(self, section, option, value): | ||
self.save_option(SystemConfigPath, section, option, value) | ||
|
||
def get(self, section, name, default=None): | ||
try: | ||
val = ConfigParser.SafeConfigParser.get(self, section, name) | ||
except Exception, e: | ||
print str(e) | ||
val = default | ||
return val | ||
|
||
def getint(self, section, name, default=0): | ||
try: | ||
val = ConfigParser.SafeConfigParser.getint(self, section, name) | ||
except: | ||
val = int(default) | ||
return val | ||
|
||
def getfloat(self, section, name, default=0.0): | ||
try: | ||
val = ConfigParser.SafeConfigParser.getfloat(self, section, name) | ||
except: | ||
val = float(default) | ||
return val | ||
|
||
def getbool(self, section, name, default=False): | ||
if self.has_option(section, name): | ||
val = self.get(section, name) | ||
if val.lower() == 'true': | ||
val = True | ||
else: | ||
val = False | ||
else: | ||
val = default | ||
return val | ||
|
||
config = Config() | ||
|
||
config.API_KEY = config.get('Credentials', 'api_key') | ||
config.SHARED_SECRET = config.get('Credentials', 'shared_secret') | ||
config.API_URL = config.get('Urls', 'starndard_api_url', 'http://www.vimeo.com/api/rest/') | ||
config.UPLOAD_URL = config.get('Urls', 'upload_url', 'http://www.vimeo.com/services/upload/') | ||
config.AUTH_URL = config.get('Urls', 'auth_url', 'http://www.vimeo.com/services/auth/') | ||
config.AUTH_TOKEN = config.get('User', 'auth_token', None) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.