Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6164fac

Browse files
authored
Create a function forchmod operations (#291)
1 parent776e649 commit6164fac

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

‎build_docs.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
importre
5555
importshlex
5656
importshutil
57+
importstat
5758
importsubprocess
5859
importsys
5960
importvenv
@@ -744,18 +745,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
744745
group=self.group,
745746
recursive=True,
746747
)
747-
run(["chmod","-R","o+r",self.checkout/"Doc"/"build"/"html"])
748-
run([
749-
"find",
750-
self.checkout/"Doc"/"build"/"html",
751-
"-type",
752-
"d",
753-
"-exec",
754-
"chmod",
755-
"o+x",
756-
"{}",
757-
";",
758-
])
748+
chmod_make_readable(self.checkout/"Doc"/"build"/"html")
759749
run([
760750
"rsync",
761751
"-a",
@@ -770,12 +760,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
770760
# Copy archive files to /archives/
771761
logging.debug("Copying dist files.")
772762
chgrp(self.checkout/"Doc"/"dist",group=self.group,recursive=True)
773-
run([
774-
"chmod",
775-
"-R",
776-
"o+r",
777-
self.checkout/"Doc"/"dist",
778-
])
763+
chmod_make_readable(self.checkout/"Doc"/"dist")
779764
run(["mkdir","-m","o+rx","-p",target/"archives"])
780765
chgrp(target/"archives",group=self.group)
781766
run([
@@ -907,6 +892,18 @@ def chgrp(
907892
logging.warning("Can't change group of %s: %s",path,str(err))
908893

909894

895+
defchmod_make_readable(path:Path,/,mode:int=stat.S_IROTH)->None:
896+
ifnotpath.is_dir():
897+
raiseValueError
898+
899+
path.chmod(path.stat().st_mode|stat.S_IROTH|stat.S_IXOTH)# o+rx
900+
forpinpath.rglob("*"):
901+
ifp.is_dir():
902+
p.chmod(p.stat().st_mode|stat.S_IROTH|stat.S_IXOTH)# o+rx
903+
else:
904+
p.chmod(p.stat().st_mode|stat.S_IROTH)# o+r
905+
906+
910907
defformat_seconds(seconds:float)->str:
911908
hours,remainder=divmod(seconds,3600)
912909
minutes,seconds=divmod(remainder,60)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp