Browse Source

"shut pkg bootstrap" now renders the version correct and in proper order (not sorted by field name)

shut
Niklas Rosenstein 10 months ago
parent
commit
2d7e261481
No known key found for this signature in database GPG Key ID: 6D269B33D25F6C6
3 changed files with 9 additions and 5 deletions
  1. + 2
    - 1
      src/shore/mapper.py
  2. + 1
    - 1
      src/shore/model.py
  3. + 6
    - 3
      src/shut/commands/pkg/bootstrap.py

+ 2
- 1
src/shore/mapper.py

@ -19,9 +19,10 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
from nr.databind.core import ObjectMapper, IDeserializer
from nr.databind.core import ObjectMapper, IDeserializer, ISerializer
from nr.databind.json import JsonModule
from shore.util.version import parse_version, Version
mapper = ObjectMapper(JsonModule())
mapper.register(Version, IDeserializer(lambda _m, n: parse_version(n.value)))
mapper.register(Version, ISerializer(lambda _m, n: str(n.value)))

+ 1
- 1
src/shore/model.py

@ -541,7 +541,7 @@ class BaseObject(Struct):
self.dump(fp)
else:
data = mapper.serialize(self, type(self), filename=file_.name, decorations=[SkipDefaults()])
yaml.safe_dump(data, file_)
yaml.safe_dump(data, file_, sort_keys=False)
def on_load_hook(self):
""" Called after the object was loaded with #load(). """

+ 6
- 3
src/shut/commands/pkg/bootstrap.py

@ -23,6 +23,7 @@ from shut.utils.io.virtual import VirtualFiles
from . import pkg
from shore.model import Author, Package, RootRequirements, VersionSelector
from shore.util.version import Version
from shore.util.license import get_license_metadata, wrap_license_text
from termcolor import colored
from typing import Optional
@ -133,14 +134,16 @@ def bootstrap(
if not target_directory:
target_directory = project_name
if not author:
author = load_author_from_git() or Author('Unknown', '<unknown@example.org>')
if not module_name:
module_name = project_name.replace('-', '_')
if not author:
author = load_author_from_git() or Author('Unknown', '<unknown@example.org>')
if not version:
version = version or Version('0.0.0')
package_manifest = Package(
name=project_name,
modulename=module_name,
modulename=None if module_name == project_name.replace('-', '_') else module_name,
version=version,
author=author,
license=license,

Loading…
Cancel
Save