Skip to content

Commit f9b1b9f

Browse files
committed
Restructure python package
1 parent 08846e3 commit f9b1b9f

12 files changed

+200
-25
lines changed

.github/workflows/build.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: build
2+
3+
on:
4+
# Triggers the workflow on push or pull request events but only for the main branch
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
#: Run the test every week
10+
schedule:
11+
- cron: '0 12 * * 1'
12+
13+
jobs:
14+
build:
15+
runs-on: ${{ matrix.os }}
16+
17+
strategy:
18+
matrix:
19+
python-version: ['3.10']
20+
os: [ubuntu-latest]
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
- name: Build
29+
run: cd python && python -m unittest

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ RefreshToken.swift
66
Package.resolved
77
.swift-version
88
.swiftpm
9-
notebooks
9+
notebooks
10+
__pycache__

README.md

+42-24
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,59 @@
1-
21
# clip2imgur <img src="./icon.png" height=40 vertical-align=bottom>
32

4-
> A simple macOS command line tool for uploading your screenshots from clipboard to Imgur
3+
> A simple macOS command line tool for uploading your screenshots from clipboard
4+
> to Imgur
55
66
[![Build Status](https://travis-ci.org/xiaohk/clip2imgur.svg?branch=master)](https://travis-ci.org/xiaohk/clip2imgur)
77
<a href="https://swift.org/package-manager/"><img src="https://img.shields.io/badge/SPM-ready-red.svg"></a>
88
[![License](https://img.shields.io/badge/License-MIT-yellowgreen)](https://github.com/xiaohk/clip2imgur/blob/master/LICENSE)
99
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5348350.svg)](https://doi.org/10.5281/zenodo.5348350)
1010

11-
1211
## Usage
12+
1313
<img src="./demo.gif" width=500 style="margin-left:50px" align="right">
1414

15-
- Press <kbd>control+shift+command+3</kbd> or <kbd>control+shift+command+4</kbd> to capture and copy a screenshot.
15+
- Press <kbd>control+shift+command+3</kbd> or <kbd>control+shift+command+4</kbd>
16+
to capture and copy a screenshot.
1617

17-
- Run `clip2imgur` in your terminal, then boom, the image URL is in your clipboard.
18+
- Run `clip2imgur` in your terminal, then boom, the image URL is in your
19+
clipboard.
1820

19-
- If it is your first time to run `clip2imgur`, you can choose to authorize this tool, and your image will be posted in your image collection (`username.imgur.com/all`).
21+
- If it is your first time to run `clip2imgur`, you can choose to authorize this
22+
tool, and your image will be posted in your image collection
23+
(`username.imgur.com/all`).
2024

21-
- You also can choose to post anonymously, but it is hard to get the url later and Imgur might delete your posts.
25+
- You also can choose to post anonymously, but it is hard to get the url later
26+
and Imgur might delete your posts.
2227

23-
In default setting, the URL of posted image will be copied to your clipboard. You can use flags to configure it.
28+
In default setting, the URL of posted image will be copied to your clipboard.
29+
You can use flags to configure it.
2430

2531
```
2632
$ clip2imgur --html
2733
$ clip2imgur -n
2834
```
2935

30-
| short | long | description |
31-
|:--|:--|:--|
32-
| `-m` | `--markdown` | URL will be copied in the Markdown image format.`[](https://i.imgur.com/x.png)` |
33-
| `-t` | `--html` | URL will be copied in the HTML image format.`<img src="https://i.imgur.com/x.png">`|
34-
| `-n` | `--notcopy` | Your image URL will not be copied to your clipboard |
36+
| short | long | description |
37+
| :---- | :----------- | :---------------------------------------------------------------------------------- |
38+
| `-m` | `--markdown` | URL will be copied in the Markdown image format.`[](https://i.imgur.com/x.png)` |
39+
| `-t` | `--html` | URL will be copied in the HTML image format.`<img src="https://i.imgur.com/x.png">` |
40+
| `-n` | `--notcopy` | Your image URL will not be copied to your clipboard |
3541

36-
Personally I like to include images in Markdown file using the HTML format, which gives more control of the display. If you forget these flags, you always can run `clip2imgur -h` to check the usage.
42+
Personally I like to include images in Markdown file using the HTML format,
43+
which gives more control of the display. If you forget these flags, you always
44+
can run `clip2imgur -h` to check the usage.
3745

3846
## Install
3947

40-
This package is built using cross-platform Swift with Swift Package Manager (SPM), but it currently only supports macOS. There are three ways to install `clip2imgur`.
48+
This package is built using cross-platform Swift with Swift Package Manager
49+
(SPM), but it currently only supports macOS. There are three ways to install
50+
`clip2imgur`.
4151

4252
### Homebrew
43-
Using `Homebrew` is the recommended and also the easiest way to get `clip2imgur` installed on your mac. If you don't have `Homebrew` installed, you can simply run:
53+
54+
Using `Homebrew` is the recommended and also the easiest way to get `clip2imgur`
55+
installed on your mac. If you don't have `Homebrew` installed, you can simply
56+
run:
4457

4558
```
4659
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@@ -54,7 +67,11 @@ $ brew install clip2imgur
5467
```
5568

5669
### Download the Binary
57-
You can download the pre-compiled binary from the [Latest Rease](https://github.com/xiaohk/clip2imgur/releases/latest). After extract the binary, you want to create a symbolic link in `/usr/local/bin` to launch `clip2imgur` in your terminal more quickly.
70+
71+
You can download the pre-compiled binary from the
72+
[Latest Rease](https://github.com/xiaohk/clip2imgur/releases/latest). After
73+
extract the binary, you want to create a symbolic link in `/usr/local/bin` to
74+
launch `clip2imgur` in your terminal more quickly.
5875

5976
```
6077
$ mkdir ~/clip2imgur && cd ~/clip2imgur
@@ -64,7 +81,11 @@ $ ln -s ~/clip2imgur/clip2imgur /usr/local/bin/clip2imgur
6481
```
6582

6683
### Build from Source
67-
This approach is not recommended, because a function used to refresh your authorization is not open sourced for security reasons. Your compiled version works fine, but may require you to re-authorize `clip2imgur` periodically. If you only want to post images anonymously, then it doesn't really matter.
84+
85+
This approach is not recommended, because a function used to refresh your
86+
authorization is not open sourced for security reasons. Your compiled version
87+
works fine, but may require you to re-authorize `clip2imgur` periodically. If
88+
you only want to post images anonymously, then it doesn't really matter.
6889

6990
To build `clip2imgur`, you need macOS 10.10 or later and Swift 3.0 or above.
7091

@@ -75,13 +96,10 @@ $ swift build -c release -Xswiftc -static-stdlib
7596
$ ln -s $(pwd)/.build/release/clip2imgur /usr/local/bin/clip2imgur
7697
```
7798

78-
`clip2imgur` also has a by-product framework `clip2imgurCore` in `./build`. There might be some handy functions to use in your own projects.
99+
`clip2imgur` also has a by-product framework `clip2imgurCore` in `./build`.
100+
There might be some handy functions to use in your own projects.
79101

80102
## Built With
103+
81104
- [Swift Package Manager](https://swift.org/package-manager/)
82105
- [Rainbow](https://github.com/onevcat/Rainbow)
83-
84-
85-
86-
87-

python/MANIFEST.in

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
include CONTRIBUTING.rst
2+
include HISTORY.rst
3+
include LICENSE
4+
include README.rst
5+
6+
recursive-include tests *
7+
recursive-exclude * __pycache__
8+
recursive-exclude * *.py[co]
9+
10+
recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
11+
12+
recursive-include clip2imgur *

python/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
README.md

python/clip2imgur/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""clip2imgur is a simple CLI that uploads your image in the clipboard to Imgur."""
2+
3+
__author__ = """Jay Wang"""
4+
__email__ = "jayw@zijie.wang"
5+
__version__ = "0.1.1"
6+
7+
from clip2imgur.clip2imgur import *
File renamed without changes.

python/requirements_dev.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pip>=22.1
2+
bump2version==0.5.11
3+
wheel==0.38.1
4+
watchdog==0.9.0
5+
flake8==3.7.8
6+
coverage==4.5.4
7+
Sphinx==1.8.5
8+
twine==1.14.0
9+
numpy>=1.15.1

python/setup.cfg

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[bumpversion]
2+
current_version = 0.1.1
3+
commit = True
4+
tag = True
5+
6+
[bumpversion:file:setup.py]
7+
search = version="{current_version}"
8+
replace = version="{new_version}"
9+
10+
[bumpversion:file:clip2imgur/__init__.py]
11+
search = __version__ = "{current_version}"
12+
replace = __version__ = "{new_version}"
13+
14+
[bdist_wheel]
15+
universal = 1
16+
17+
[flake8]
18+
exclude = docs

python/setup.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python
2+
3+
"""The setup script."""
4+
5+
from json import loads
6+
from setuptools import setup, find_packages
7+
from pathlib import Path
8+
9+
with open("README.md") as readme_file:
10+
readme = readme_file.read()
11+
12+
requirements = ["pyobjc", "pyperclip", "rich"]
13+
14+
test_requirements = []
15+
16+
setup(
17+
author="Jay Wang",
18+
author_email="jayw@zijie.wang",
19+
python_requires=">=3.6",
20+
platforms="Linux, Mac OS X, Windows",
21+
keywords=[
22+
"Imgur",
23+
"CLI",
24+
"Image",
25+
"Clipboard",
26+
],
27+
classifiers=[
28+
"License :: OSI Approved :: MIT License",
29+
"Programming Language :: Python",
30+
"Programming Language :: Python :: 3",
31+
"Programming Language :: Python :: 3.6",
32+
"Programming Language :: Python :: 3.7",
33+
"Programming Language :: Python :: 3.8",
34+
"Programming Language :: Python :: 3.9",
35+
"Framework :: Jupyter",
36+
"Framework :: Jupyter :: JupyterLab",
37+
"Framework :: Jupyter :: JupyterLab :: 3",
38+
],
39+
description="A simple CLI that uploads your image in the clipboard to Imgur.",
40+
install_requires=requirements,
41+
license="MIT license",
42+
long_description=readme,
43+
long_description_content_type="text/markdown",
44+
include_package_data=True,
45+
name="clip2imgur",
46+
packages=find_packages(include=["clip2imgur", "clip2imgur.*"]),
47+
test_suite="tests",
48+
tests_require=test_requirements,
49+
url="https://github.com/xiaohk/clip2imgur",
50+
version="0.1.1",
51+
zip_safe=False,
52+
)

python/tests/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Unit test package for clip2imgur."""

python/tests/test_clip2imgur.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
3+
"""Tests for `clip2imgur` package."""
4+
5+
6+
import unittest
7+
8+
from clip2imgur import clip2imgur
9+
10+
11+
class TestClip2imgur(unittest.TestCase):
12+
"""Tests for `timbertrek` package."""
13+
14+
def setUp(self):
15+
"""Set up test fixtures, if any."""
16+
17+
def tearDown(self):
18+
"""Tear down test fixtures, if any."""
19+
20+
def test_clip2imgur(self):
21+
"""Test something."""
22+
cli = clip2imgur.Clip2imgurApp()
23+
cli.run()
24+
25+
26+
if __name__ == "__main__":
27+
unittest.main()

0 commit comments

Comments
 (0)