mirror of
https://github.com/fmhy/edit.git
synced 2026-02-18 09:11:33 +11:00
improve
This commit is contained in:
parent
eea17da08a
commit
e886f8dfbf
1 changed files with 26 additions and 28 deletions
48
.github/single-page.py
vendored
48
.github/single-page.py
vendored
|
|
@ -1,37 +1,35 @@
|
||||||
import glob # Import the glob module, which allows for file name pattern matching
|
import glob
|
||||||
import time # Import the time module, which provides various time-related functions
|
import time
|
||||||
|
|
||||||
|
|
||||||
def output():
|
def output():
|
||||||
# Read all markdown files in the current directory, excluding README.md, feedback.md, posts.md, and index.md
|
|
||||||
read = glob.glob("*.md")
|
read = glob.glob("*.md")
|
||||||
content = "" # Initialize an empty string to store the combined content of all markdown files
|
content = ""
|
||||||
nsfw_content = "" # Initialize an empty string to store the content of the NSFWPiracy.md file
|
nsfw_content = ""
|
||||||
|
|
||||||
for file in read:
|
for file in read:
|
||||||
if (
|
if file in EXCLUDED_FILES:
|
||||||
file != "README.md"
|
continue
|
||||||
or file != "feedback.md"
|
|
||||||
or file != "posts.md"
|
|
||||||
or file != "index.md"
|
|
||||||
):
|
|
||||||
with open(file, "r") as f: # Open each file in read mode
|
|
||||||
if "NSFWPiracy.md" == file:
|
|
||||||
nsfw_content += f.read() # If the file is NSFWPiracy.md, add its content to nsfw_content
|
|
||||||
continue # Skip to the next iteration of the loop
|
|
||||||
content += f.read() # Add the content of the current file to content
|
|
||||||
|
|
||||||
return content + nsfw_content # Return the combined content of all markdown files and the NSFWPiracy.md file
|
if file == "NSFWPiracy.md":
|
||||||
|
with open(file, "r") as f:
|
||||||
|
nsfw_content += f.read()
|
||||||
|
continue
|
||||||
|
|
||||||
|
with open(file, "r") as f:
|
||||||
|
content += f.read()
|
||||||
|
|
||||||
|
return content + nsfw_content
|
||||||
|
|
||||||
|
EXCLUDED_FILES = {"README.md", "feedback.md", "posts.md", "index.md"}
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
content = output() # Call the output function and store its result in the content variable
|
content = output()
|
||||||
with open("single-page", "w") as file: # Open a new file named "single-page" in write mode
|
|
||||||
file.write(content) # Write the content to the "single-page" file
|
|
||||||
|
|
||||||
|
with open("single-page", "w") as file:
|
||||||
|
file.write(content)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
s = time.perf_counter() # Record the start time
|
s = time.perf_counter()
|
||||||
main() # Call the main function
|
main()
|
||||||
elapsed = time.perf_counter() - s # Calculate the elapsed time
|
elapsed = time.perf_counter() - s
|
||||||
print(f"{__file__} executed in {elapsed:0.2f} seconds.") # Print the elapsed time and the name of the executed file
|
print(f"{__file__} executed in {elapsed:0.2f} seconds.")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue