File tree Expand file tree Collapse file tree 3 files changed +20
-11
lines changed
Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Original file line number Diff line number Diff line change 11from __future__ import absolute_import
2- from .client import Embedly , __version__
2+ from .client import Embedly
3+
4+ __version__ = '0.4.3'
Original file line number Diff line number Diff line change 1717from .models import Url
1818
1919
20- __version__ = '0.4.3'
21- USER_AGENT = 'Mozilla/5.0 (compatible; embedly-python/%s;)' % __version__
20+ def get_user_agent ():
21+ from . import __version__
22+ return 'Mozilla/5.0 (compatible; embedly-python/%s;)' % __version__
2223
2324
2425class Embedly (object ):
2526 """
2627 Client
2728
2829 """
29- def __init__ (self , key = None , user_agent = USER_AGENT , timeout = 60 ):
30+ def __init__ (self , key = None , user_agent = None , timeout = 60 ):
3031 """
3132 Initialize the Embedly client
3233
33- :param user_agent: User Agent passed to Embedly
34- :type user_agent: str
3534 :param key: Embedly Pro key
3635 :type key: str
36+ :param user_agent: User Agent passed to Embedly
37+ :type user_agent: str
38+ :param timeout: timeout for HTTP connection attempts
39+ :type timeout: int
3740
3841 :returns: None
3942 """
40- self .user_agent = user_agent
41- self .timeout = timeout
4243 self .key = key
43- self .services = []
44+ self .user_agent = user_agent or get_user_agent ()
45+ self .timeout = timeout
4446
47+ self .services = []
4548 self ._regex = None
4649
4750 def get_services (self ):
Original file line number Diff line number Diff line change 1010if sys .version_info [:2 ] < (2 , 6 ):
1111 required .append ('simplejson' )
1212
13- version = __import__ ('embedly' ).__version__
13+ def get_version ():
14+ with open (os .path .join ('embedly' , '__init__.py' )) as f :
15+ for line in f :
16+ if line .startswith ('__version__ =' ):
17+ return line .split ('=' )[1 ].strip ().strip ('"\' ' )
1418
1519if os .path .exists ("README.rst" ):
1620 long_description = codecs .open ("README.rst" , "r" , "utf-8" ).read ()
2024
2125setup (
2226 name = 'Embedly' ,
23- version = version ,
27+ version = get_version () ,
2428 author = 'Embed.ly, Inc.' ,
2529 author_email = 'support@embed.ly' ,
2630 description = 'Python Library for Embedly' ,
You can’t perform that action at this time.
0 commit comments