Browse Source

refs #1 - Скрипт удаление непубличных файлов

tags/3.11.0
parent
commit
c730bb1bfe
2 changed files with 74 additions and 0 deletions
  1. +4
    -0
      3.0/filelist.txt
  2. +70
    -0
      3.0/remove_private_source.py

+ 4
- 0
3.0/filelist.txt View File

@@ -1,3 +1,7 @@
/filelist.txt
/gpl-2.0.txt
/license.txt
/remove_private_source.py
/doc/Schemas/
/scripts/build/runtimes/common.xml
/scripts/build/runtimes/terminal_common.xml


+ 70
- 0
3.0/remove_private_source.py View File

@@ -0,0 +1,70 @@
import io
import os

# Windows filesystem ONLY
# for linux remove .lower() calls


def get_public_filenames():
f = open('filelist.txt', 'r')
x = f.readlines()

result = []
for l in x:
result.append(l.strip().lower())

return result

def get_all_files():
files = []
for (dirpath, dirnames, filenames) in os.walk("."):
path = dirpath.replace(".\\", "/").replace("\\", "/")
for f in filenames:
if path == ".":
files.append("/" + f.lower())
else:
files.append(path.lower() + "/" + f.lower())
return files

def is_dir(p):
return os.path.isdir(os.getcwd() + p.replace("/", "\\"))



public_files = set(get_public_filenames())

for f in get_all_files():

is_public = f in public_files
if is_public:
continue
ff = f.split("/")
for i in range(2, len(ff) + 1):
path = "/".join(ff[0:i])
path = path + "/" if is_dir(path) else path
is_public = is_public or (path in public_files)
if is_public:
break
if is_public:
continue
print("Remove ", f)
os.remove(os.getcwd() + f.replace("/", "\\"))










Loading…
Cancel
Save