FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-quantities/setup.py at master · python-quantities/python-quantities · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python-quantities
/
python-quantities
Public
Notifications
You must be signed in to change notification settings
Fork
76
Star
219
Code
Issues
72
Pull requests
5
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python-quantities
/
setup.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
54 lines (39 loc) · 1.64 KB
Breadcrumbs
python-quantities
/
setup.py
Copy path
File metadata and controls
executable file
·
54 lines (39 loc) · 1.64 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from
setuptools
import
Command
,
setup
from
setuptools
.
command
.
build_py
import
build_py
as
_build
from
setuptools
.
command
.
sdist
import
sdist
as
_sdist
from
datetime
import
datetime
class
data
(
Command
):
description
=
"Convert the NIST database of constants"
user_options
=
[]
boolean_options
=
[]
def
initialize_options
(
self
):
pass
def
finalize_options
(
self
):
pass
def
run
(
self
):
with
open
(
'quantities/constants/NIST_codata.txt'
)
as
f
:
data
=
f
.
read
()
data
=
data
.
split
(
'
\n
'
)[
10
:
-
1
]
with
open
(
'quantities/constants/_codata.py'
,
'w'
)
as
f
:
f
.
write
(
'# THIS FILE IS AUTOMATICALLY GENERATED
\n
'
)
f
.
write
(
'# ANY CHANGES MADE HERE WILL BE LOST
\n
'
)
f
.
write
(
f'# LAST GENERATED:
{
datetime
.
now
()
}
\n
\n
'
)
f
.
write
(
'physical_constants = {}
\n
\n
'
)
for
line
in
data
:
name
=
line
[:
55
].
rstrip
().
replace
(
'mag.'
,
'magnetic'
)
name
=
name
.
replace
(
'mom.'
,
'moment'
)
val
=
line
[
55
:
77
].
replace
(
' '
,
''
).
replace
(
'...'
,
''
)
prec
=
line
[
77
:
99
].
replace
(
' '
,
''
).
replace
(
'(exact)'
,
'0'
)
unit
=
line
[
99
:].
rstrip
().
replace
(
' '
,
'*'
).
replace
(
'^'
,
'**'
)
d
=
"{'value': %s, 'precision': %s, 'units': '%s'}"
\
%
(
val
,
prec
,
unit
)
f
.
write
(
"physical_constants['%s'] = %s
\n
"
%
(
name
,
d
))
class
sdist
(
_sdist
):
def
run
(
self
):
self
.
run_command
(
'data'
)
_sdist
.
run
(
self
)
class
build
(
_build
):
def
run
(
self
):
self
.
run_command
(
'data'
)
_build
.
run
(
self
)
setup
(
cmdclass
=
{
"build_py"
:
build
,
"sdist"
:
sdist
,
"data"
:
data
})
Back
|
FazBrowse Home
|
New Git URL