-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 630b038
Showing
7 changed files
with
627 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Keypirinha Package Control | ||
========================== | ||
|
||
This is a package for the fast keystroke launcher keypirinha | ||
(http://keypirinha.com/). It provides commands to install, update and remove | ||
third party packages. | ||
|
||
## Usage | ||
|
||
All commands are prefixed with `PackageControl:`. | ||
|
||
## Installation | ||
|
||
### Directly from Keypirinha | ||
|
||
* Open the `Keypirinha: Console` | ||
* Enter the following: | ||
```python | ||
import keypirinha as kp,keypirinha_net as kpn,os;p="PackageControl.keypirinha-package";d=kpn.build_urllib_opener().open("https://github.com/ueffel/Keypirinha-PackageControl/releases/download/0.1/"+p);pb=d.read();d.close();pp=os.path.join(kp.installed_package_dir(), p);f=open(pp, "wb");f.write(pb);f.close() | ||
``` | ||
|
||
### Manually | ||
|
||
* Download the `PackageControl.keypirinha-package` from the [releases](https://github.com/ueffel/Keypirinha-PackageControl/releases/latest) | ||
* Copy the file in your %APPDATA%\Keypirinha\InstalledPackages directory (or <Keypirinha_Home>\portable\Profile\InstalledPackages) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
@echo off | ||
set PACKAGE_NAME=PackageControl | ||
|
||
set SEVENZIP= | ||
where 7z > nul 2>&1 | ||
if not errorlevel 1 ( | ||
set SEVENZIP=7z | ||
goto done_sevenzip | ||
) | ||
|
||
where 7za > nul 2>&1 | ||
if not errorlevel 1 ( | ||
set SEVENZIP=7za | ||
goto done_sevenzip | ||
) | ||
|
||
if exist "c:\Program Files (x86)\7-Zip\7z.exe" ( | ||
set "SEVENZIP=c:\Program Files (x86)\7-Zip\7z.exe" | ||
goto done_sevenzip | ||
) | ||
|
||
if exist "c:\Program Files (x86)\7-Zip\7za.exe" ( | ||
set "SEVENZIP=c:\Program Files (x86)\7-Zip\7za.exe" | ||
goto done_sevenzip | ||
) | ||
|
||
if exist "c:\Program Files\7-Zip\7z.exe" ( | ||
set "SEVENZIP=c:\Program Files\7-Zip\7z.exe" | ||
goto done_sevenzip | ||
) | ||
|
||
if exist "c:\Program Files\7-Zip\7za.exe" ( | ||
set "SEVENZIP=c:\Program Files\7-Zip\7za.exe" | ||
goto done_sevenzip | ||
) | ||
|
||
if not defined SEVENZIP ( | ||
echo 7zip not found | ||
exit /b 1 | ||
) | ||
:done_sevenzip | ||
|
||
:pack | ||
if exist %PACKAGE_NAME%.keypirinha-package ( | ||
del %PACKAGE_NAME%.keypirinha-package | ||
) | ||
echo Using "%SEVENZIP%" to pack | ||
"%SEVENZIP%" a -mx9 ^ | ||
-tzip "%PACKAGE_NAME%.keypirinha-package" ^ | ||
-x!%~nx0 ^ | ||
-xr!.git ^ | ||
-x@.gitignore ^ | ||
-x!.gitignore ^ | ||
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import json | ||
import os | ||
|
||
|
||
class Package: | ||
""" | ||
Represents a keypirinha package | ||
""" | ||
def __init__(self, name, version, desc, date, dl_url, filename): | ||
self.name = name | ||
self.version = version | ||
self.description = desc | ||
self.date = date | ||
self.download_url = dl_url | ||
self.filename = filename if filename else "{}.keypirinha-package".format(name) | ||
|
||
def download(self, opener, directory): | ||
""" | ||
Downloads the file from download_url and saves it to the given directory | ||
""" | ||
with opener.open(self.download_url) as dl, \ | ||
open(os.path.join(directory, self.filename), "wb") as package: | ||
for chunk in iter(lambda: dl.read(4096), ""): | ||
if not chunk: | ||
break | ||
package.write(chunk) | ||
os.utime(os.path.join(directory, self.filename), times=(self.date.timestamp(), self.date.timestamp())) | ||
|
||
def to_dict(self): | ||
""" | ||
Creates a dictionary from the package object | ||
""" | ||
obj = { | ||
"download_url": self.download_url, | ||
"name": self.name, | ||
"filename": self.filename, | ||
"date": self.date.strftime("%Y-%m-%dT%H:%M:%S%z"), | ||
"description": self.description, | ||
"version": self.version | ||
} | ||
return obj | ||
|
||
def to_json(self): | ||
""" | ||
Create json string from the package object | ||
""" | ||
return json.dumps(self.to_dict(), sort_keys=True, indent=4) | ||
|
||
def __repr__(self): | ||
""" | ||
Readable representation of the package object (json) | ||
""" | ||
return self.to_json() |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[main] | ||
# Decides which packages are available to install | ||
repository = http://ueffel.bplaced.de/uni/packages.json | ||
|
||
# List of the installed packages | ||
# this list is automatically updated, no need to add anything here in the file directly | ||
# installed packages are checked on startup, if anything isn't present, it will be installed | ||
#installed_packages = |
Oops, something went wrong.