2222import tempfile
2323import webbrowser
2424
25+ sys .path .append ('/home/nick/git/pybadges/' )
2526import pybadges
2627from pybadges .version import __version__
2728
@@ -37,11 +38,8 @@ def main():
3738 help = 'the text to show on the left-hand-side of the badge' )
3839 parser .add_argument (
3940 '--right-text' ,
40- default = 'APACHE' ,
41+ default = None ,
4142 help = 'the text to show on the right-hand-side of the badge' )
42- parser .add_argument ('--whole-link' ,
43- default = None ,
44- help = 'the url to redirect to when the badge is clicked' )
4543 parser .add_argument (
4644 '--left-link' ,
4745 default = None ,
@@ -52,6 +50,18 @@ def main():
5250 default = None ,
5351 help = 'the url to redirect to when the right-hand of the badge is ' +
5452 'clicked' )
53+ parser .add_argument (
54+ '--center-link' ,
55+ default = None ,
56+ help = 'the url to redirect to when the center of the badge is ' +
57+ 'clicked' )
58+ parser .add_argument ('--whole-link' ,
59+ default = None ,
60+ help = 'the url to redirect to when the badge is clicked' )
61+ parser .add_argument (
62+ '--logo' ,
63+ default = None ,
64+ help = 'a URI reference to a logo to display in the badge' )
5565 parser .add_argument (
5666 '--left-color' ,
5767 default = '#555' ,
@@ -61,19 +71,9 @@ def main():
6171 default = '#007ec6' ,
6272 help = 'the background color of the right-hand-side of the badge' )
6373 parser .add_argument (
64- '--logo ' ,
74+ '--center-color ' ,
6575 default = None ,
66- help = 'a URI reference to a logo to display in the badge' )
67- parser .add_argument (
68- '--embed-logo' ,
69- nargs = '?' ,
70- type = lambda x : x .lower () in ['y' , 'yes' , 't' , 'true' , '1' , '' ],
71- const = 'yes' ,
72- default = 'no' ,
73- help = 'if the logo is specified then include the image data directly in '
74- 'the badge (this will prevent a URL fetch and may work around the '
75- 'fact that some browsers do not fetch external image references); '
76- 'only works if --logo is a HTTP/HTTPS URI or a file path' )
76+ help = 'the background color of the right-hand-side of the badge' )
7777 parser .add_argument ('--browser' ,
7878 action = 'store_true' ,
7979 default = False ,
@@ -91,11 +91,6 @@ def main():
9191 help = 'the path to the ttf font file containing DejaVu Sans. If not ' +
9292 'present on your system, you can download it from ' +
9393 'https://www.fontsquirrel.com/fonts/dejavu-sans' )
94- parser .add_argument (
95- '--whole-title' ,
96- default = None ,
97- help = 'the title to associate with the entire badge. See '
98- 'https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title' )
9994 parser .add_argument (
10095 '--left-title' ,
10196 default = None ,
@@ -106,16 +101,67 @@ def main():
106101 default = None ,
107102 help = 'the title to associate with the right part of the badge. See '
108103 'https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title' )
104+ parser .add_argument (
105+ '--center-title' ,
106+ default = None ,
107+ help = 'the title to associate with the center part of the badge. See '
108+ 'https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title' )
109+ parser .add_argument (
110+ '--whole-title' ,
111+ default = None ,
112+ help = 'the title to associate with the entire badge. See '
113+ 'https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title' )
114+ parser .add_argument (
115+ '--right-image' ,
116+ default = None ,
117+ help = 'the image to associate with the right-hand side of the badge' )
118+ parser .add_argument (
119+ '--center-image' ,
120+ default = None ,
121+ help = 'the image to associate with the center of the badge' )
122+ parser .add_argument (
123+ '--embed-logo' ,
124+ nargs = '?' ,
125+ type = lambda x : x .lower () in ['y' , 'yes' , 't' , 'true' , '1' , '' ],
126+ const = 'yes' ,
127+ default = 'no' ,
128+ help = 'if the logo is specified then include the image data directly in '
129+ 'the badge (this will prevent a URL fetch and may work around the '
130+ 'fact that some browsers do not fetch external image references); '
131+ 'only works if --logo is a HTTP/HTTPS URI or a file path' )
132+ parser .add_argument (
133+ '--embed-right-image' ,
134+ nargs = '?' ,
135+ type = lambda x : x .lower () in ['y' , 'yes' , 't' , 'true' , '1' , '' ],
136+ const = 'yes' ,
137+ default = 'no' ,
138+ help =
139+ 'if the right image is specified then include the image data directly in '
140+ 'the badge (this will prevent a URL fetch and may work around the '
141+ 'fact that some browsers do not fetch external image references); '
142+ 'only works if --logo is a HTTP/HTTPS URI or a file path' )
143+ parser .add_argument (
144+ '--embed-center-image' ,
145+ nargs = '?' ,
146+ type = lambda x : x .lower () in ['y' , 'yes' , 't' , 'true' , '1' , '' ],
147+ const = 'yes' ,
148+ default = 'no' ,
149+ help =
150+ 'if the center image is specified then include the image data directly in '
151+ 'the badge (this will prevent a URL fetch and may work around the '
152+ 'fact that some browsers do not fetch external image references); '
153+ 'only works if --logo is a HTTP/HTTPS URI or a file path' )
109154 parser .add_argument (
110155 '-v' ,
111156 '--version' ,
112157 action = 'version' ,
113158 version = '%(prog)s {version}' .format (version = __version__ ))
114159 args = parser .parse_args ()
115160
116- if (args .left_link or args .right_link ) and args .whole_link :
161+ if (args .left_link or args .right_link or
162+ args .center_link ) and args .whole_link :
117163 print ('argument --whole-link: cannot be set with ' +
118- '--left-link or --right-link' ,
164+ '--left-link, --right-link, or --center_link ' ,
119165 file = sys .stderr )
120166 sys .exit (1 )
121167
@@ -133,15 +179,22 @@ def main():
133179 right_text = args .right_text ,
134180 left_link = args .left_link ,
135181 right_link = args .right_link ,
182+ center_link = args .center_link ,
136183 whole_link = args .whole_link ,
184+ logo = args .logo ,
137185 left_color = args .left_color ,
138186 right_color = args .right_color ,
139- logo = args .logo ,
187+ center_color = args .center_color ,
140188 measurer = measurer ,
141- embed_logo = args .embed_logo ,
142- whole_title = args .whole_title ,
143189 left_title = args .left_title ,
144- right_title = args .right_title )
190+ right_title = args .right_title ,
191+ center_title = args .center_title ,
192+ whole_title = args .whole_title ,
193+ right_image = args .right_image ,
194+ center_image = args .center_image ,
195+ embed_logo = args .embed_logo ,
196+ embed_right_image = args .embed_right_image ,
197+ embed_center_image = args .embed_center_image )
145198
146199 if args .browser :
147200 _ , badge_path = tempfile .mkstemp (suffix = '.svg' )
0 commit comments