Skip to content

Commit

Permalink
pw_module: Update SEED filename in creation command
Browse files Browse the repository at this point in the history
http://pwrev.dev/248452 removed the SEED name from filenames, making
them only the SEED number. This updates the `pw seed` command to use
this new filename style.

Fixes: 380283196
Change-Id: Ic9255c4a31346ccfd754c1b02b21ccd7081681e3
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/250512
Docs-Not-Needed: Alexei Frolov <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
Lint: Lint 🤖 <[email protected]>
Reviewed-by: Kayce Basques <[email protected]>
Pigweed-Auto-Submit: Alexei Frolov <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
  • Loading branch information
frolv authored and CQ Bot Account committed Nov 21, 2024
1 parent 620d2ad commit 2944c9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
5 changes: 1 addition & 4 deletions pw_module/py/pw_module/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ class SeedMetadata:
sources: Optional[List[str]] = None

def default_filename(self) -> str:
normalized_title = self.title.lower().replace(' ', '-')
normalized_title = re.sub(r'[^a-zA-Z0-9_-]', '', normalized_title)

return f'{self.number:04d}-{normalized_title}.rst'
return f'{self.number:04d}.rst'


class SeedRegistry:
Expand Down
20 changes: 10 additions & 10 deletions pw_module/py/seed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@
import("seed.gni")
pw_seed("0001") {
sources = [ "0001-the-seed-process.rst" ]
inputs = [ "0001-the-seed-process/seed-index-gerrit.png" ]
sources = [ "0001.rst" ]
inputs = [ "0001/seed-index-gerrit.png" ]
title = "The SEED Process"
status = "Meta"
author = "The Pigweed Authors"
facilitator = "N/A"
}
pw_seed("0002") {
sources = [ "0002-template.rst" ]
sources = [ "0002.rst" ]
title = "SEED Template"
status = "Meta"
author = "The Pigweed Authors"
facilitator = "N/A"
}
pw_seed_index("seeds") {
index_file = "0000-index.rst"
index_file = "0000.rst"
seeds = [
":0001",
":0002",
Expand All @@ -58,16 +58,16 @@
import("seed.gni")
pw_seed("0001") {
sources = [ "0001-the-seed-process.rst" ]
inputs = [ "0001-the-seed-process/seed-index-gerrit.png" ]
sources = [ "0001.rst" ]
inputs = [ "0001/seed-index-gerrit.png" ]
title = "The SEED Process"
status = "Meta"
author = "The Pigweed Authors"
facilitator = "N/A"
}
pw_seed("0002") {
sources = [ "0002-template.rst" ]
sources = [ "0002.rst" ]
title = "SEED Template"
status = "Meta"
author = "The Pigweed Authors"
Expand All @@ -82,7 +82,7 @@
}
pw_seed_index("seeds") {
index_file = "0000-index.rst"
index_file = "0000.rst"
seeds = [
":0001",
":0002",
Expand All @@ -102,7 +102,7 @@ def test_default_filename_basic(self):
authors='',
status=seed.SeedStatus.DRAFT,
)
self.assertEqual(meta.default_filename(), '0789-simple-title-2.rst')
self.assertEqual(meta.default_filename(), '0789.rst')

def test_default_filename_special_characters(self):
meta = seed.SeedMetadata(
Expand All @@ -113,7 +113,7 @@ def test_default_filename_special_characters(self):
)
self.assertEqual(
meta.default_filename(),
'9876-pw_some_module-pigweeds-newest-module.rst',
'9876.rst',
)


Expand Down

0 comments on commit 2944c9a

Please sign in to comment.