FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pytype/build_scripts/pytype_copy.py at master · ucifs/pytype · GitHub
ucifs
/
pytype
Public
forked from
google/pytype
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pytype
/
build_scripts
/
pytype_copy.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (36 loc) · 1.37 KB
Breadcrumbs
pytype
/
build_scripts
/
pytype_copy.py
Copy path
File metadata and controls
46 lines (36 loc) · 1.37 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
#! /usr/bin/python -B
"""Copy a group of files from a source directory to a destination directory.
Usage:
copy.py -s <SOURCE_DIRECTORY> -d <DESTINATION_DIRECTORY> file1 [file2 ...]
"""
import
argparse
import
os
import
shutil
import
sys
def
parse_args
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"-s"
,
"--src_dir"
,
type
=
str
,
required
=
True
,
help
=
"The source directory."
)
parser
.
add_argument
(
"-d"
,
"--dst_dir"
,
type
=
str
,
required
=
True
,
help
=
"The destination directory."
)
parser
.
add_argument
(
"file_list"
,
metavar
=
"FILE"
,
type
=
str
,
nargs
=
"+"
,
help
=
"List of files to copy."
)
args
=
parser
.
parse_args
()
return
args
def
copy_file
(
src_dir
,
dst_dir
,
filename
):
dst_file
=
os
.
path
.
join
(
dst_dir
,
filename
)
dst_parent
=
os
.
path
.
dirname
(
dst_file
)
if
not
os
.
path
.
exists
(
dst_parent
):
# Create the intermediate directories if they do not exist
os
.
makedirs
(
dst_parent
)
shutil
.
copy
(
os
.
path
.
join
(
src_dir
,
filename
),
dst_file
)
def
main
():
args
=
parse_args
()
if
not
os
.
path
.
exists
(
args
.
src_dir
):
sys
.
exit
(
"Source directory '%s' does not exist."
%
args
.
src_dir
)
if
not
os
.
path
.
exists
(
args
.
dst_dir
):
sys
.
exit
(
"Destination directory '%s' does not exist"
%
args
.
dst_dir
)
for
filename
in
args
.
file_list
:
copy_file
(
args
.
src_dir
,
args
.
dst_dir
,
filename
)
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL