File tree Expand file tree Collapse file tree 3 files changed +29
-12
lines changed Expand file tree Collapse file tree 3 files changed +29
-12
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,10 @@ test: clean
10
10
11
11
clean :
12
12
@find . -name ' *.pyc' -delete
13
- @rm -rf tmp\
14
- ua_parser.egg-info\
15
- dist\
16
- build
13
+ @rm -rf tmp \
14
+ ua_parser.egg-info \
15
+ dist \
16
+ build \
17
+ ua_parser/_regexes.py
17
18
18
19
.PHONY : all test clean
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ $ pip install ua-parser
16
16
### Manual install
17
17
In the top-level directory run:
18
18
```
19
- $ make
19
+ $ python setup.py install
20
20
```
21
21
22
22
##Getting Started
52
52
>>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
53
53
>>> parsed_string = user_agent_parser.ParseUserAgent(ua_string)
54
54
>>> pp.pprint(parsed_string)
55
- { 'family': 'Chrome',
56
- 'major': '41',
57
- 'minor': '0',
55
+ { 'family': 'Chrome',
56
+ 'major': '41',
57
+ 'minor': '0',
58
58
'patch': '2272'}
59
59
```
60
60
@@ -84,13 +84,13 @@ $ make
84
84
>>> ua_string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36'
85
85
>>> parsed_string = user_agent_parser.ParseDevice(ua_string)
86
86
>>> pp.pprint(parsed_string)
87
- { 'brand': None,
88
- 'family': 'Other',
87
+ { 'brand': None,
88
+ 'family': 'Other',
89
89
'model': None}
90
90
```
91
91
92
92
93
93
## Copyright
94
94
95
- Copyright 2008 Google Inc. See ua_parser/LICENSE for more information
95
+ Copyright 2008 Google Inc. See ua_parser/LICENSE for more information
96
96
Original file line number Diff line number Diff line change 2
2
import os
3
3
from distutils import log
4
4
from distutils .core import Command
5
+ from distutils .command .build import build as _build
5
6
from setuptools import setup
6
7
from setuptools .command .develop import develop as _develop
7
8
from setuptools .command .sdist import sdist as _sdist
9
+ from setuptools .command .install import install as _install
8
10
9
11
10
12
def check_output (* args , ** kwargs ):
@@ -49,7 +51,7 @@ def force_bytes(text):
49
51
import yaml
50
52
py_dest = os .path .join (work_path , 'ua_parser' , '_regexes.py' )
51
53
52
- log .info ('Compiling regexes.yaml -> _regexes.py' )
54
+ log .info ('compiling regexes.yaml -> _regexes.py' )
53
55
with open (yaml_src , 'rb' ) as fp :
54
56
regexes = yaml .safe_load (fp )
55
57
with open (py_dest , 'wb' ) as fp :
@@ -109,13 +111,27 @@ def run(self):
109
111
_develop .run (self )
110
112
111
113
114
+ class build (_build ):
115
+ def run (self ):
116
+ self .run_command ('build_regexes' )
117
+ _build .run (self )
118
+
119
+
120
+ class install (_install ):
121
+ def run (self ):
122
+ self .run_command ('build_regexes' )
123
+ _install .run (self )
124
+
125
+
112
126
class sdist (_sdist ):
113
127
sub_commands = _sdist .sub_commands + [('build_regexes' , None )]
114
128
115
129
116
130
cmdclass = {
117
131
'develop' : develop ,
132
+ 'build' : build ,
118
133
'sdist' : sdist ,
134
+ 'install' : install ,
119
135
'build_regexes' : build_regexes ,
120
136
}
121
137
You can’t perform that action at this time.
0 commit comments