Skip to content

Commit

Permalink
Merge pull request #8 from Ayehavgunne/develop
Browse files Browse the repository at this point in the history
preparing for initial release
  • Loading branch information
Ayehavgunne authored Oct 14, 2021
2 parents 0966c8a + 73d90a2 commit c20b9f3
Show file tree
Hide file tree
Showing 19 changed files with 379 additions and 39 deletions.
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Changelog for ``thsl``

### Current Version: 0.1.0

# Release Notes

### 0.1.0
Initial Release

#### Added
- Comments
- Trailing Commas
- Supports loading a thsl file into Python with the following types
- Dicts
- Lists
- Sets
- Tuples
- Ints
- Bytes
- Strings
- Chars
- Bools
- Ints
- Floats
- Decimals
- Strings
- Chars
- Binary
- Hexes
- Octals
- Base64
- Complex numbers
- Ranges
- Dates
- DateTimes
- Intervals
- IP Addresses
- URLs
- Environment Variables
- Paths
- Semantic Version Numbers
- Regex patterns
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
86 changes: 86 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make
via issue, email, or any other method with the owners of this repository before making
a change.

Please note we have a code of conduct, please follow it in all your interactions with
the project.

## Pull Requests

Please use the autoformatters iSort and Black and validate the code using MyPy. It is
not always possible to make MyPy entirely happy without silencing some type errors but
at least do what you can and use the comment `# type: ignore` sparingly. Lastly, try to
provide the most acurate type hints possible.

## Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and
maintainers pledge to making participation in our project and our community a
harassment-free experience for everyone, regardless of age, body size, disability,
ethnicity, gender identity and expression, level of experience, nationality, personal
appearance, race, religion, or sexual identity and orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery for unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional
setting

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior
and are expected to take appropriate and fair corrective action in response to any
instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are not
aligned to this Code of Conduct, or to ban temporarily or permanently any contributor
for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

### Scope

This Code of Conduct applies both within project spaces and in public spaces when an
individual is representing the project or its community. Examples of representing a
project or community include using an official project e-mail address, posting via an
official social media account, or acting as an appointed representative at an online or
offline event. Representation of a project may be further defined and clarified by
project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
contacting the project team at [email protected]. All complaints will be
reviewed and investigated and will result in a response that is deemed necessary and
appropriate to the circumstances. The project team is obligated to maintain
confidentiality with regard to the reporter of an incident. Further details of specific
enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may
face temporary or permanent repercussions as determined by other members of the
project's leadership.

### Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Anthony Nelson Post

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
recursive-include thsl *.py
include requirements.txt
include CHANGELOG.md
42 changes: 36 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,33 @@ Indentation is done via tabs only

See [sample.thsl](sample.thsl) for more.

## Install
This is currently a beta level project

```commandline
pip install thsl
```

## Usage
```python
>>> from pathlib import Path
>>> import thsl

>>> data = thsl.load(Path("data.thsl"))
{
'debug': False,
'name': 'My Name',
'graphics': {
'target_framerate': 60,
'fullscreen': False,
'resolution': {
'width': 1920,
'height': 1080
}
}
}
```

## Features
Not finalized. Subject to change

Expand Down Expand Up @@ -64,12 +91,16 @@ Not finalized. Subject to change
- [x] Ranges
- [x] exclusive
- [x] inclusive
- [x] Dates
- [x] Times
- [x] DateTimes
- [x] Intervals
- [x] Dates (with the help of the dateutil library)
- [x] Times (with the help of the dateutil library)
- [x] DateTimes (with the help of the dateutil library)
- [x] Intervals (with the help of the tempora library)
- [x] IP Addresses
- [x] URLs
- [x] Environment Variables
- [x] Paths
- [x] Semantic Version Numbers (using the semantic_version library)
- [x] Regex
- Inheritance
- Interfaces
- Type Aliases
Expand All @@ -85,8 +116,6 @@ Not finalized. Subject to change
- conversion would be lossy unless only compatible types are used
- YAML or JSON input
- zlib (de)compression
- regex
- semantic version numbers
- type addon system

## Benefits
Expand Down Expand Up @@ -132,6 +161,7 @@ maintain it in one place.
- [ ] string templating

## Other TODO:
- [ ] dump to file
- [ ] Finalize grammar and token structure
- [ ] Python code generation
- [ ] Code generation for other languages
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
python-dateutil==2.8.2
tempora==4.1.1
semantic_version==2.8.5
16 changes: 9 additions & 7 deletions sample.thsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name_single_quotes .str: 'My name is {name}' # single quotes allow templating
escaping .str: "My \"Name "

# currently the colon is not required but it helps with readability
less_readable .int -3
less_readable .int 3

# curly braces need escaping to be included in single quotes
escaping_single_quotes .str: 'My name is \{{name}\}'
Expand All @@ -25,7 +25,10 @@ graphics:
height .int: 1080
key .str # defaults to empty string
key_without_value .float # defaults to 0
# null is not an option by default, a nullable decorator is available to mark as such

# null is not an option by default, a nullable decorator is available to mark as such
@nullable
nullable_key .float # will be null
# indentation has to be a tab

a_char .char: a # can only be a single character
Expand All @@ -36,7 +39,7 @@ string is
lines.
"

"keys can be in quotes" .int: 1 # for keys to have spaces it must be in quotes
"keys can be in quotes" .int: 1 # for a key to have spaces it must be in quotes

# no need to worry about using type identifiers as keys or values
int .int: 1
Expand Down Expand Up @@ -124,16 +127,15 @@ dict_one_liner: {one .int: 1, two .float: 2}

# structs are very similar to dictionaries but can be handled differently by the consuming language
# Python could create a dataclass for example
# either dynamically or human readable code can be generated
# either dynamically or human-readable code can be generated
MyStruct .struct:
nested_struct .struct:
NestedStruct .struct:
first .int: 1 # provided values will be defaults for a struct
second .int: 2
enum_dict .dict: # dict type is optional
my_dict:
third .float: 3
fourth: .str: 4
key .str: value
key_without_value .float
recursion .MyStruct # maybe, maybe not

AnotherStruct .struct:
Expand Down
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[mypy]
disallow_untyped_defs = True
disallow_untyped_calls = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
pretty = True
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
with open('CHANGELOG.md', 'r') as fh:
for line in fh.readlines():
if 'Current Version: ' in line:
version = line.replace('Current Version: ', '')
version = line.replace('Current Version: ', '').strip()
break

with open("README.md", "r") as fh:
Expand All @@ -12,8 +12,11 @@
with open("requirements.txt", "r") as fh:
requirements = fh.readlines()

with open("dev_requirements.txt", "r") as fh:
dev_requirements = fh.readlines()
try:
with open("dev_requirements.txt", "r") as fh:
dev_requirements = fh.readlines()
except FileNotFoundError:
dev_requirements = []

setup(
name="thsl",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_lexer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from src.grammar import TokenType
from src.lexer import Lexer, Token
from thsl.grammar import TokenType
from thsl.lexer import Lexer, Token


@pytest.fixture
Expand Down
Loading

0 comments on commit c20b9f3

Please sign in to comment.