Commit
Β·
c90dbdd
1
Parent(s):
02488fa
updated
Browse files- .github/scripts/update_stats.py +44 -13
- README.md +5 -5
.github/scripts/update_stats.py
CHANGED
@@ -85,20 +85,51 @@ def update_readme():
|
|
85 |
content = file.read()
|
86 |
|
87 |
# Check if we need to add a download statistics section with the image
|
88 |
-
if "## Download Statistics" not in content and "![Download Statistics]" not in content:
|
89 |
-
# Find a good place to insert the download statistics section
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
95 |
else:
|
96 |
-
# Insert at the
|
97 |
-
content
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
with open(README_PATH, 'w') as file:
|
104 |
file.write(content)
|
|
|
85 |
content = file.read()
|
86 |
|
87 |
# Check if we need to add a download statistics section with the image
|
88 |
+
if "## Cumulative Download Statistics" not in content and "![Cumulative Download Statistics]" not in content:
|
89 |
+
# Find a good place to insert the download statistics section - after the badges and before navigation index
|
90 |
+
badge_line = ""
|
91 |
+
navigation_index = "## π Navigation Index"
|
92 |
+
|
93 |
+
if badge_line in content and navigation_index in content:
|
94 |
+
# Insert after the badges and before navigation index
|
95 |
+
parts = content.split(badge_line)
|
96 |
+
badge_part = parts[0] + badge_line
|
97 |
+
rest_parts = parts[1].split(navigation_index)
|
98 |
+
|
99 |
+
content = badge_part + "\n\n## Cumulative Download Statistics\n\n\n\n" + navigation_index + rest_parts[1]
|
100 |
else:
|
101 |
+
# Fallback: Insert at the beginning of the file
|
102 |
+
content = content.split("---\n", 2)
|
103 |
+
if len(content) >= 3:
|
104 |
+
content = "---\n" + content[1] + "---\n" + "## Cumulative Download Statistics\n\n\n\n" + content[2]
|
105 |
+
else:
|
106 |
+
content = "## Cumulative Download Statistics\n\n\n\n" + content[0]
|
107 |
+
|
108 |
+
# Update existing section if it exists but is in the wrong place
|
109 |
+
elif "## Cumulative Download Statistics" in content:
|
110 |
+
# First remove the existing section
|
111 |
+
section_start = content.find("## Cumulative Download Statistics")
|
112 |
+
section_end = content.find("\n\n", section_start + 30) # Look for the end of the section
|
113 |
+
if section_end == -1: # If not found, try to find the next heading
|
114 |
+
section_end = content.find("\n##", section_start + 30)
|
115 |
+
if section_end == -1: # If still not found, just use the rest of the content
|
116 |
+
section_end = len(content)
|
117 |
+
else:
|
118 |
+
section_end += 2 # Include the newlines
|
119 |
+
|
120 |
+
section_content = content[section_start:section_end]
|
121 |
+
content = content.replace(section_content, "")
|
122 |
+
|
123 |
+
# Then add it in the right place
|
124 |
+
badge_line = ""
|
125 |
+
navigation_index = "## π Navigation Index"
|
126 |
+
|
127 |
+
if badge_line in content and navigation_index in content:
|
128 |
+
parts = content.split(badge_line)
|
129 |
+
badge_part = parts[0] + badge_line
|
130 |
+
rest_parts = parts[1].split(navigation_index)
|
131 |
+
|
132 |
+
content = badge_part + "\n\n## Cumulative Download Statistics\n\n\n\n" + navigation_index + rest_parts[1]
|
133 |
|
134 |
with open(README_PATH, 'w') as file:
|
135 |
file.write(content)
|
README.md
CHANGED
@@ -11,7 +11,11 @@ pretty_name: IFVI Value Factors - Derivative Dataset For Analysis
|
|
11 |
[](https://huggingface.co/datasets/danielrosehill/ifvi_valuefactors_deriv)
|
12 |
[](https://ifvi.org/methodology/environmental-topic-methodology/interim-methodologies/#GlobalValueFactorDatabase)
|
13 |
|
14 |
-

|
142 |
-
|
143 |
<a id="release-notes-for-v2"></a>
|
144 |
|
145 |
---
|
|
|
11 |
[](https://huggingface.co/datasets/danielrosehill/ifvi_valuefactors_deriv)
|
12 |
[](https://ifvi.org/methodology/environmental-topic-methodology/interim-methodologies/#GlobalValueFactorDatabase)
|
13 |
|
14 |
+

|
15 |
+
|
16 |
+
## Cumulative Download Statistics
|
17 |
+
|
18 |
+

|
19 |
|
20 |
## π Navigation Index
|
21 |
|
|
|
140 |
|
141 |
The repository is configured with GitHub Actions to automatically update download statistics daily.
|
142 |
|
|
|
|
|
|
|
|
|
143 |
<a id="release-notes-for-v2"></a>
|
144 |
|
145 |
---
|