Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0c4e393

Browse filesBrowse files
committed
Initial Commit
- Split Module into multiple id sub-modules - Split Validation String & Validation into separate files - Created README.md - Created CHANGELOG.md
0 parents  commit 0c4e393
Copy full SHA for 0c4e393

File tree

Expand file treeCollapse file tree

11 files changed

+654
-0
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+654
-0
lines changed

‎.gitignore

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
/Cargo.lock

‎CHANGELOG.md

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!--Markdownlint Rules-->
2+
<!-- markdownlint-disable no-duplicate-header-->
3+
4+
# Changelog
5+
6+
All notable changes to this project will be documented in this file.
7+
8+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
9+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
10+
11+
## [0.0.1] - 2022-09-03
12+
13+
### Added
14+
15+
- Created Baseline Project

‎Cargo.toml

Copy file name to clipboard
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "pyver"
3+
description = "Python PEP-440 Version Parsing"
4+
authors = ["Allstreamer <allstreamer.contact@gmail.com>"]
5+
license = "MIT"
6+
version = "0.1.0"
7+
keywords = ["versions", "python"]
8+
readme = "README.md"
9+
edition = "2021"
10+
repository = "https://github.com/Allstreamer/pyver"
11+
12+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
13+
14+
[dependencies]
15+
anyhow = { version = "1" }
16+
serde = { version = "1", features = ["derive"] }
17+
regex = { version = "1" }
18+
lazy_static = { version = "1.4.0" }
19+
pomsky-macro = { version = "0.6.0" }
20+
derivative = { version = "2.2.0" }

‎README.md

Copy file name to clipboard
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# PyVer (WIP)
2+
3+
[![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](LICENSE-MIT)
4+
5+
> **Python PEP-440 Version Parsing**
6+
7+
This package allows for parsing Python PEP-440 version numbers and comparisons between PEP-440 Versions
8+
9+
## Usage
10+
11+
```Toml
12+
[dependencies]
13+
pyver = "0.0.1"
14+
```
15+
16+
```Rust
17+
use pyver::PackageVersion;
18+
19+
let a = PackageVersion::new("v1.0a2.dev456").unwrap();
20+
let b = PackageVersion::new("v1.0a2.dev457").unwrap();
21+
22+
assert_eq!(a < b, true);
23+
```
24+
25+
26+
## Contribution
27+
28+
For now Contributions will be quite loose but soon we will be switching to a rolling release model

‎src/ids/dev_id.rs

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//! # `PEP-440` Developmental release identifier
2+
3+
use serde::{Deserialize, Serialize};
4+
5+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, PartialOrd)]
6+
pub struct DevHead {
7+
pub dev_num: Option<u32>,
8+
}

‎src/ids/mod.rs

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! # Identifiers
2+
//! Importing
3+
//! ```
4+
//! use pyver::ids::{PreHeader, PostHeader, PostHead, DevHead, ReleaseHeader};
5+
//! ```
6+
7+
mod dev_id;
8+
mod post_id;
9+
mod pre_id;
10+
mod release_id;
11+
12+
pub use dev_id::*;
13+
pub use post_id::*;
14+
pub use pre_id::*;
15+
pub use release_id::*;

‎src/ids/post_id.rs

Copy file name to clipboard
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
use serde::{Deserialize, Serialize};
2+
use std::cmp::Ordering;
3+
4+
/// # `PEP-440` Post-Release identifier
5+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
6+
pub struct PostHeader {
7+
pub post_head: Option<PostHead>,
8+
pub post_num: Option<u32>,
9+
}
10+
11+
/// `PEP-440` Post-Release Identifier Keyword
12+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
13+
pub enum PostHead {
14+
Post,
15+
Rev,
16+
}
17+
18+
impl PartialOrd for PostHead {
19+
fn partial_cmp(&self, _other: &Self) -> Option<Ordering> {
20+
Some(Ordering::Equal)
21+
}
22+
}
23+
24+
impl PartialOrd for PostHeader {
25+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
26+
if self.post_num == other.post_num {
27+
return Some(Ordering::Equal);
28+
}
29+
30+
if self.post_num.is_none() && other.post_num.is_some() {
31+
return Some(Ordering::Less);
32+
} else if self.post_num.is_some() && other.post_num.is_none() {
33+
return Some(Ordering::Greater);
34+
}
35+
36+
if self.post_num < other.post_num {
37+
Some(Ordering::Less)
38+
} else {
39+
Some(Ordering::Greater)
40+
}
41+
}
42+
}

‎src/ids/pre_id.rs

Copy file name to clipboard
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! # `PEP-440` Pre-Release identifier
2+
3+
use serde::{Deserialize, Serialize};
4+
5+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, PartialOrd)]
6+
pub enum PreHeader {
7+
/// Present in versions like 1.1beta1 or 1.0b1 both are represented the same way
8+
/// ```
9+
///# use pyver::ids::PreHeader;
10+
///
11+
/// PreHeader::Beta(Some(1));
12+
/// ```
13+
Beta(Option<u32>),
14+
/// Present in versions like 1.0alpha2 or 1.0a2 both are represented the same way
15+
/// ```
16+
///# use pyver::ids::PreHeader;
17+
///
18+
/// PreHeader::Alpha(Some(2));
19+
/// ```
20+
Alpha(Option<u32>),
21+
/// Present in versions like 1.1pre3
22+
/// ```
23+
///# use pyver::ids::PreHeader;
24+
///
25+
/// PreHeader::Preview(Some(3));
26+
/// ```
27+
Preview(Option<u32>),
28+
/// Present in versions like 1.1-rc-4 or 1.1c-4
29+
/// ```
30+
///# use pyver::ids::PreHeader;
31+
///
32+
/// PreHeader::ReleaseCandidate(Some(4));
33+
/// ```
34+
ReleaseCandidate(Option<u32>),
35+
}

‎src/ids/release_id.rs

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
/// `PEP-440` Release numbers
4+
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, PartialOrd)]
5+
pub struct ReleaseHeader {
6+
/// Major release such as 1.0 or breaking changes
7+
pub major: u32,
8+
/// Minor release Such as new functionality
9+
pub minor: u32,
10+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.