nava 0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nava/__init__.py +7 -0
- nava/__main__.py +23 -0
- nava/errors.py +8 -0
- nava/functions.py +136 -0
- nava/params.py +13 -0
- nava-0.1.dist-info/AUTHORS.md +12 -0
- nava-0.1.dist-info/LICENSE +21 -0
- nava-0.1.dist-info/METADATA +178 -0
- nava-0.1.dist-info/RECORD +12 -0
- nava-0.1.dist-info/WHEEL +5 -0
- nava-0.1.dist-info/entry_points.txt +2 -0
- nava-0.1.dist-info/top_level.txt +1 -0
nava/__init__.py
ADDED
nava/__main__.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Nava main."""
|
|
3
|
+
|
|
4
|
+
import sys
|
|
5
|
+
from art import tprint
|
|
6
|
+
from .params import NAVA_VERSION
|
|
7
|
+
from .functions import nava_help
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main():
|
|
11
|
+
"""
|
|
12
|
+
CLI main function.
|
|
13
|
+
|
|
14
|
+
:return: None
|
|
15
|
+
"""
|
|
16
|
+
args = sys.argv
|
|
17
|
+
tprint("nava")
|
|
18
|
+
tprint("V:" + NAVA_VERSION)
|
|
19
|
+
nava_help()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
main()
|
nava/errors.py
ADDED
nava/functions.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Nava functions."""
|
|
3
|
+
import sys
|
|
4
|
+
import subprocess
|
|
5
|
+
import os
|
|
6
|
+
import shlex
|
|
7
|
+
|
|
8
|
+
from .params import OVERVIEW, SOUND_FILE_PLAY_ERROR, SOUND_FILE_EXIST_ERROR, SOUND_FILE_PATH_TYPE_ERROR
|
|
9
|
+
from .errors import NavaBaseError
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def nava_help():
|
|
13
|
+
"""
|
|
14
|
+
Print nava details.
|
|
15
|
+
|
|
16
|
+
:return: None
|
|
17
|
+
"""
|
|
18
|
+
print(OVERVIEW)
|
|
19
|
+
print("Repo : https://github.com/openscilab/nava")
|
|
20
|
+
print("Webpage : https://openscilab.com/")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def quote(func):
|
|
24
|
+
"""
|
|
25
|
+
Quote the given shell string.
|
|
26
|
+
|
|
27
|
+
:return: inner function
|
|
28
|
+
"""
|
|
29
|
+
def inner_function(*args, **kwargs):
|
|
30
|
+
"""
|
|
31
|
+
Inner function.
|
|
32
|
+
|
|
33
|
+
:param args: non-keyword arguments
|
|
34
|
+
:type args: list
|
|
35
|
+
:param kwargs: keyword arguments
|
|
36
|
+
:type kwargs: dict
|
|
37
|
+
:return: modified function result
|
|
38
|
+
"""
|
|
39
|
+
sound_path = args[0]
|
|
40
|
+
sound_path = shlex.quote(sound_path)
|
|
41
|
+
args[0] = sound_path
|
|
42
|
+
return func(*args, **kwargs)
|
|
43
|
+
return inner_function
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def __play_win(sound_path):
|
|
47
|
+
"""
|
|
48
|
+
Play sound in Windows.
|
|
49
|
+
|
|
50
|
+
:param sound_path: sound path
|
|
51
|
+
:type sound_path: str
|
|
52
|
+
:return: None
|
|
53
|
+
"""
|
|
54
|
+
import winsound
|
|
55
|
+
winsound.PlaySound(sound_path, winsound.SND_FILENAME)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@quote
|
|
59
|
+
def __play_linux(sound_path):
|
|
60
|
+
"""
|
|
61
|
+
Play sound in Linux.
|
|
62
|
+
|
|
63
|
+
:param sound_path: sound path
|
|
64
|
+
:type sound_path: str
|
|
65
|
+
:return: None
|
|
66
|
+
"""
|
|
67
|
+
_ = subprocess.check_call(["aplay",
|
|
68
|
+
sound_path],
|
|
69
|
+
shell=False,
|
|
70
|
+
stderr=subprocess.PIPE,
|
|
71
|
+
stdin=subprocess.PIPE,
|
|
72
|
+
stdout=subprocess.PIPE)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@quote
|
|
76
|
+
def __play_mac(sound_path):
|
|
77
|
+
"""
|
|
78
|
+
Play sound in macOS.
|
|
79
|
+
|
|
80
|
+
:param sound_path: sound path
|
|
81
|
+
:type sound_path: str
|
|
82
|
+
:return: None
|
|
83
|
+
"""
|
|
84
|
+
_ = subprocess.check_call(["afplay",
|
|
85
|
+
sound_path],
|
|
86
|
+
shell=False,
|
|
87
|
+
stderr=subprocess.PIPE,
|
|
88
|
+
stdin=subprocess.PIPE,
|
|
89
|
+
stdout=subprocess.PIPE)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def path_check(func):
|
|
93
|
+
"""
|
|
94
|
+
Check the given path to be a string and a valid file directory.
|
|
95
|
+
|
|
96
|
+
:return: inner function
|
|
97
|
+
"""
|
|
98
|
+
def inner_function(*args, **kwargs):
|
|
99
|
+
"""
|
|
100
|
+
Inner function.
|
|
101
|
+
|
|
102
|
+
:param args: non-keyword arguments
|
|
103
|
+
:type args: list
|
|
104
|
+
:param kwargs: keyword arguments
|
|
105
|
+
:type kwargs: dict
|
|
106
|
+
:return: modified function result
|
|
107
|
+
"""
|
|
108
|
+
sound_path = args[0]
|
|
109
|
+
if not (isinstance(sound_path, str)):
|
|
110
|
+
raise NavaBaseError(SOUND_FILE_PATH_TYPE_ERROR)
|
|
111
|
+
# check sound file existance
|
|
112
|
+
if not (os.path.isfile(sound_path)):
|
|
113
|
+
raise NavaBaseError(SOUND_FILE_EXIST_ERROR)
|
|
114
|
+
return func(*args, **kwargs)
|
|
115
|
+
return inner_function
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@path_check
|
|
119
|
+
def play(sound_path):
|
|
120
|
+
"""
|
|
121
|
+
Play sound.
|
|
122
|
+
|
|
123
|
+
:param sound_path: sound path
|
|
124
|
+
:type sound_path: str
|
|
125
|
+
:return: None
|
|
126
|
+
"""
|
|
127
|
+
try:
|
|
128
|
+
sys_platform = sys.platform
|
|
129
|
+
if sys_platform == "win32":
|
|
130
|
+
__play_win(sound_path)
|
|
131
|
+
elif sys_platform == "darwin":
|
|
132
|
+
__play_mac(sound_path)
|
|
133
|
+
else:
|
|
134
|
+
__play_linux(sound_path)
|
|
135
|
+
except Exception:
|
|
136
|
+
raise NavaBaseError(SOUND_FILE_PLAY_ERROR)
|
nava/params.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Nava parameters."""
|
|
3
|
+
|
|
4
|
+
NAVA_VERSION = "0.1"
|
|
5
|
+
|
|
6
|
+
OVERVIEW = """
|
|
7
|
+
A Python library for playing sound everywhere natively and securely.
|
|
8
|
+
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
SOUND_FILE_PLAY_ERROR = "Sound can not play due to some issues."
|
|
12
|
+
SOUND_FILE_EXIST_ERROR = "Given sound file doesn't exist."
|
|
13
|
+
SOUND_FILE_PATH_TYPE_ERROR = "Sound file's path should be a string."
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Authors #
|
|
2
|
+
|
|
3
|
+
----------
|
|
4
|
+
- Sepand Haghighi - Open Science Laboratory ([Github](https://github.com/sepandhaghighi))
|
|
5
|
+
- Sadra Sabouri - Open Science Laboratory ([Github](https://github.com/sadrasabouri)) **
|
|
6
|
+
- Amirhossein Rostami - Open Science Laboratory ([Github](https://github.com/AHReccese))
|
|
7
|
+
- Alireza Zolanvari - Open Science Laboratory ([Github](https://github.com/AlirezaZolanvari))
|
|
8
|
+
|
|
9
|
+
** **Maintainer**
|
|
10
|
+
|
|
11
|
+
# Other Contributors #
|
|
12
|
+
----------
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 OpenSciLab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: nava
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: A Python library for playing sound everywhere natively and securely.
|
|
5
|
+
Home-page: https://github.com/openscilab/nava
|
|
6
|
+
Download-URL: https://github.com/openscilab/nava/tarball/v0.1
|
|
7
|
+
Author: OpenSciLab Development Team
|
|
8
|
+
Author-email: info@openscilab.com
|
|
9
|
+
License: MIT
|
|
10
|
+
Project-URL: Webpage, https://openscilab.com/
|
|
11
|
+
Project-URL: Source, https://github.com/openscilab/nava
|
|
12
|
+
Project-URL: Discord, https://discord.gg/MCbPKCFBs3
|
|
13
|
+
Keywords: sound wav music mp3 player audio
|
|
14
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Natural Language :: English
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Intended Audience :: Developers
|
|
26
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
27
|
+
Classifier: Intended Audience :: Manufacturing
|
|
28
|
+
Classifier: Topic :: Multimedia
|
|
29
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
30
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Players
|
|
31
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Players :: MP3
|
|
32
|
+
Requires-Python: >=3.6
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
License-File: LICENSE
|
|
35
|
+
License-File: AUTHORS.md
|
|
36
|
+
Requires-Dist: art (>=1.8)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
<div align="center">
|
|
40
|
+
<h1>Nava</h1>
|
|
41
|
+
<br/>
|
|
42
|
+
<a href="https://www.python.org/">
|
|
43
|
+
<img src="https://img.shields.io/badge/built%20with-Python3-green.svg" alt="built with Python3"/>
|
|
44
|
+
</a>
|
|
45
|
+
<a href="https://badge.fury.io/py/nava">
|
|
46
|
+
<img src="https://badge.fury.io/py/nava.svg" alt="PyPI version" height="18">
|
|
47
|
+
</a>
|
|
48
|
+
<a href="https://discord.gg/MCbPKCFBs3">
|
|
49
|
+
<img src="https://img.shields.io/discord/1064533716615049236.svg" alt="Discord Channel">
|
|
50
|
+
</a>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
## Table of contents
|
|
54
|
+
* [Overview](https://github.com/openscilab/nava#overview)
|
|
55
|
+
* [Installation](https://github.com/openscilab/nava#installation)
|
|
56
|
+
* [Usage](https://github.com/openscilab/nava#usage)
|
|
57
|
+
* [Issues & Bug Reports](https://github.com/openscilab/nava#issues--bug-reports)
|
|
58
|
+
* [Contribution](https://github.com/openscilab/nava/blob/main/.github/CONTRIBUTING.md)
|
|
59
|
+
* [Authors](https://github.com/openscilab/nava/blob/main/AUTHORS.md)
|
|
60
|
+
* [License](https://github.com/openscilab/nava/blob/main/LICENSE)
|
|
61
|
+
* [Show Your Support](https://github.com/openscilab/nava#show-your-support)
|
|
62
|
+
* [Changelog](https://github.com/openscilab/nava/blob/main/CHANGELOG.md)
|
|
63
|
+
* [Code of Conduct](https://github.com/openscilab/nava/blob/main/.github/CODE_OF_CONDUCT.md)
|
|
64
|
+
|
|
65
|
+
## Overview
|
|
66
|
+
|
|
67
|
+
<p align="justify">
|
|
68
|
+
Nava is a Python library that allows users to play sound in Python without any dependencies or platform restrictions. It is a cross-platform solution that runs on any operating system, including Windows, macOS, and Linux. Its lightweight and easy-to-use design makes Nava an ideal choice for developers looking to add sound functionality to their Python programs.
|
|
69
|
+
</p>
|
|
70
|
+
|
|
71
|
+
<table>
|
|
72
|
+
<tr>
|
|
73
|
+
<td align="center">PyPI Counter</td>
|
|
74
|
+
<td align="center">
|
|
75
|
+
<a href="http://pepy.tech/project/nava">
|
|
76
|
+
<img src="http://pepy.tech/badge/nava">
|
|
77
|
+
</a>
|
|
78
|
+
</td>
|
|
79
|
+
</tr>
|
|
80
|
+
<tr>
|
|
81
|
+
<td align="center">Github Stars</td>
|
|
82
|
+
<td align="center">
|
|
83
|
+
<a href="https://github.com/openscilab/nava">
|
|
84
|
+
<img src="https://img.shields.io/github/stars/openscilab/nava.svg?style=social&label=Stars">
|
|
85
|
+
</a>
|
|
86
|
+
</td>
|
|
87
|
+
</tr>
|
|
88
|
+
</table>
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
<table>
|
|
93
|
+
<tr>
|
|
94
|
+
<td align="center">Branch</td>
|
|
95
|
+
<td align="center">main</td>
|
|
96
|
+
<td align="center">dev</td>
|
|
97
|
+
</tr>
|
|
98
|
+
<tr>
|
|
99
|
+
<td align="center">CI</td>
|
|
100
|
+
<td align="center"><img src="https://github.com/openscilab/nava/workflows/CI/badge.svg?branch=main"></td>
|
|
101
|
+
<td align="center"><img src="https://github.com/openscilab/nava/workflows/CI/badge.svg?branch=dev"></td>
|
|
102
|
+
</tr>
|
|
103
|
+
</table>
|
|
104
|
+
|
|
105
|
+
## Installation
|
|
106
|
+
|
|
107
|
+
### PyPI
|
|
108
|
+
|
|
109
|
+
- Check [Python Packaging User Guide](https://packaging.python.org/installing/)
|
|
110
|
+
- Run `pip install nava==0.1` (Need root access)
|
|
111
|
+
|
|
112
|
+
### Source code
|
|
113
|
+
- Download [Version 0.1](https://github.com/openscilab/nava/archive/v0.1.zip) or [Latest Source](https://github.com/openscilab/nava/archive/dev.zip)
|
|
114
|
+
- Run `pip install .`
|
|
115
|
+
|
|
116
|
+
## Usage
|
|
117
|
+
|
|
118
|
+
### Basic
|
|
119
|
+
```python
|
|
120
|
+
from nava import play
|
|
121
|
+
play("alarm.wav")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Error
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from nava import play, NavaBaseError
|
|
128
|
+
|
|
129
|
+
try:
|
|
130
|
+
play("alarm.wav")
|
|
131
|
+
except NavaBaseError as e:
|
|
132
|
+
print(str(e))
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
## Issues & bug reports
|
|
137
|
+
|
|
138
|
+
Just fill an issue and describe it. We'll check it ASAP! or send an email to [info@openscilab.com](mailto:info@openscilab.com "info@openscilab.com").
|
|
139
|
+
|
|
140
|
+
- Please complete the issue template
|
|
141
|
+
|
|
142
|
+
You can also join our discord server
|
|
143
|
+
|
|
144
|
+
<a href="https://discord.gg/MCbPKCFBs3">
|
|
145
|
+
<img src="https://img.shields.io/discord/1064533716615049236.svg?style=for-the-badge" alt="Discord Channel">
|
|
146
|
+
</a>
|
|
147
|
+
|
|
148
|
+
## Show your support
|
|
149
|
+
|
|
150
|
+
<h3>Star this repo</h3>
|
|
151
|
+
|
|
152
|
+
Give a ⭐️ if this project helped you!
|
|
153
|
+
|
|
154
|
+
<h3>Donate to our project</h3>
|
|
155
|
+
|
|
156
|
+
If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-) .
|
|
157
|
+
|
|
158
|
+
<a href="https://openscilab.com/#donation" target="_blank"><img src="https://github.com/openscilab/nava/raw/main/others/donation.png" height="90px" width="270px" alt="Nava Donation"></a>
|
|
159
|
+
|
|
160
|
+
# Changelog
|
|
161
|
+
All notable changes to this project will be documented in this file.
|
|
162
|
+
|
|
163
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
164
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
165
|
+
|
|
166
|
+
## [Unreleased]
|
|
167
|
+
## [0.1] - 2023-06-10
|
|
168
|
+
### Added
|
|
169
|
+
- `README.md`
|
|
170
|
+
- `__play_win` function
|
|
171
|
+
- `__play_linux` function
|
|
172
|
+
- `__play_mac` function
|
|
173
|
+
- `quote` function
|
|
174
|
+
- `path_check` function
|
|
175
|
+
- `play` function
|
|
176
|
+
|
|
177
|
+
[Unreleased]: https://github.com/openscilab/nava/compare/v0.1...dev
|
|
178
|
+
[0.1]: https://github.com/openscilab/nava/compare/bd789cc...v0.1
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
nava/__init__.py,sha256=jt0KwfSj0_RPGmvB_3cTSBfyGuHNsUNW3_JNRqlsxLw,167
|
|
2
|
+
nava/__main__.py,sha256=s8rfqfzeo9NuqDxHp95ssgsc_vaVj3bUpHt1frXU4Eg,341
|
|
3
|
+
nava/errors.py,sha256=DcAQRBWHsgqDqH4qcaYVgrJycviftBcNr8PtRSHWDXg,120
|
|
4
|
+
nava/functions.py,sha256=oFwvxXtQljAs-mKCKvd2hJM3J-Z3myQESyOkhORScjo,3294
|
|
5
|
+
nava/params.py,sha256=ZATW4FZHdb8PaZfUpQ0BE1lK_SCGGBIHRO5GrmYrE1Y,353
|
|
6
|
+
nava-0.1.dist-info/AUTHORS.md,sha256=WxLMi_dKyn72bgiYdQ45PUOGer2uvl2s7a3IJwnmg3Q,441
|
|
7
|
+
nava-0.1.dist-info/LICENSE,sha256=sI8dHP17u-qnTdGoz5fjzaMXWjaP3NIzxS7gjFAnqiY,1067
|
|
8
|
+
nava-0.1.dist-info/METADATA,sha256=EnM1_cQUzA7p6e5gcBuPVezubGUaVySjts4-velNM0w,6169
|
|
9
|
+
nava-0.1.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
|
10
|
+
nava-0.1.dist-info/entry_points.txt,sha256=3UdEnHIwuFBoD8Qxy6XVEt2XX_m7rU8b1RjeQ6nuLVI,44
|
|
11
|
+
nava-0.1.dist-info/top_level.txt,sha256=St0Kjb4xD-0zmAF20p98QY-NOTQfeRVzWVZbwSnKGGw,5
|
|
12
|
+
nava-0.1.dist-info/RECORD,,
|
nava-0.1.dist-info/WHEEL
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nava
|