Skip to content

Commit

Permalink
update CI and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
CNOCTAVE committed Nov 13, 2024
1 parent 581fb68 commit 7aaeab4
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 19 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Build and Publish

on:
release:
types: [created]

jobs:
linux-build:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
path: 'octave_tar'
# uncomment this on demand
# - run: sudo chmod a+x octave_tar/src/configure
# uncomment this on demand
- run: sudo chmod -R a+x octave_tar/inst
- run: tar --warning=no-file-changed --exclude='octave_tar/.git' --exclude='octave_tar/.github' -czvf octave_tar.tar.gz octave_tar
- run: gh release upload 1.0.1 octave_tar.tar.gz --repo $GITHUB_REPOSITORY
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: octave_tar
Version: 1.0.0
Date: 2024-11-07
Version: 1.0.1
Date: 2024-11-13
Author: various authors
Maintainer: Yu Hongbo <[email protected]>, CNOCTAVE <[email protected]>
Title: tar wrapper
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
** v1.0.1
Add CI build workflow.
Add document for extracting to current dir.
-------------------------------------------------------
** v1.0.0
Add document website.
Add bug tracker website.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
2. Translate en-US.html into English.
3. Add dropdown like the picture below to every *.html.
For example, add dropdown "en-US English".
![the dropdown looking](./docs/pic/translate_dropdown.png)
![the dropdown looking](./docs/translate_dropdown.png)
The code for adding dropdown is like the picture below.
![the dropdown code](./docs/pic/translate_dropdown_code.png)
![the dropdown code](./docs/translate_dropdown_code.png)
4. PR to octave_tar.
File renamed without changes
8 changes: 5 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<link href="https://use.fontawesome.com/releases/v6.1.1/css/all.css" rel="stylesheet" type="text/css">
<link href="https://cdn.jsdelivr.net/npm/animate.css@^4.0.0/animate.min.css" rel="stylesheet" type="text/css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/quasar.prod.css" rel="stylesheet" type="text/css">
<link href="assets/main.css" rel="stylesheet" type="text/css">
<link href="main.css" rel="stylesheet" type="text/css">
<title>octave_tar文档</title>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
Expand Down Expand Up @@ -143,7 +143,7 @@

<q-page-container>
<div style="position: relative;">
<q-img src="pic/banner0.png" spinner-color="white" style="width: 100%; height: 300px;"></q-img>
<q-img src="banner0.png" spinner-color="white" style="width: 100%; height: 300px;"></q-img>
<div class="q-mx-md rainbow-text"
style="line-height: 300px; font-size: 100px; position: absolute; left: 0%; top: 0%;">octave_tar文档
</div>
Expand All @@ -158,7 +158,7 @@
<div id="online_install" class="title1 q-ma-md text-primary">在线安装</div>
<p class="q-ma-md">octave_tar可以在线安装。</p>
<div class="text-h5 q-ma-md text-red-10">在线安装octave_tar,代码如下:</div>
<p class="q-ma-md">>> pkg install 'https://github.com/CNOCTAVE/octave_tar/releases/download/1.0.0/octave_tar.tar.gz'</p>
<p class="q-ma-md">>> pkg install 'https://github.com/CNOCTAVE/octave_tar/releases/download/1.0.1/octave_tar.tar.gz'</p>
<q-separator></q-separator>
<div id="source_code_install" class="title1 q-ma-md text-primary">源码安装</div>
<p class="q-ma-md">octave_tar可以直接使用tar包安装。</p>
Expand Down Expand Up @@ -193,6 +193,8 @@
<p class="q-ma-md">>> tar_pack("file", "dir", "new.tar")</p>
<div class="text-h5 q-ma-md text-red-10">解包一个名为file.tar的文件至new_file文件夹,代码如下:</div>
<p class="q-ma-md">>> tar_unpack("file.tar", "new_file")</p>
<div class="text-h5 q-ma-md text-red-10">解包一个名为file.tar的文件至当前文件夹,代码如下:</div>
<p class="q-ma-md">>> tar_unpack("file.tar", ".")</p>
<q-separator></q-separator>
<div id="references" class="title1 q-ma-md text-primary">引用octave_tar</div>
<div class="text-h5 q-ma-md text-red-10">如果你在学术研究中涉及octave_tar,那么可以按需引用以下内容。</div>
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion inst/tar_pack.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
if nargin < 2
print_usage();
endif
[ret, status] = python("tar_pack.py", varargin{:})
[ret, status] = python("tar_pack.py", varargin{:});
end
34 changes: 28 additions & 6 deletions inst/tar_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@
import sys
import tarfile
import os
import warnings
from builtins import UserWarning

class output(UserWarning):
pass

def custom_warning_format(message, category, filename, lineno, file=None, line=None):
formatted_message = f"{category.__name__}: {message}"
print(formatted_message, end='\n')

# 设置自定义的警告显示处理函数
warnings.showwarning = custom_warning_format

def print_log(message, category=output, stacklevel=1, source=None):
"""Logger function.
1. You cannot call print() to directly print to Octave terminal.
2. Octave package doesn't allow to make deeper Python package dir.
So use this instead."""
warnings.warn(message, category, stacklevel, source)

if len(sys.argv) < 3:
print("Usage: tar_pack(source1, source2, ... , output_filename)")
Expand All @@ -25,12 +44,15 @@
def tar_directory(source_list_output_filename):
source_list = source_list_output_filename[:-1]
output_filename = source_list_output_filename[-1]


with tarfile.open(output_filename, "w:") as tar:
for path in source_list:
tar.add(path, arcname=os.path.basename(path))
print(f"Source {path} has been tarred to {output_filename}.")
try:
with tarfile.open(output_filename, "w:") as tar:
for path in source_list:
tar.add(path, arcname=os.path.basename(path))
print_log(f"Source {path} has been tarred to {output_filename}.")
return 0
except BaseException as e:
print_log(e)
return 1

if __name__ == "__main__":
tar_directory(sys.argv[1:])
2 changes: 1 addition & 1 deletion inst/tar_unpack.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
if nargin < 2
print_usage();
endif
[ret, status] = python("tar_unpack.py", tar_filename, destination_dir)
[ret, status] = python("tar_unpack.py", tar_filename, destination_dir);
end
31 changes: 27 additions & 4 deletions inst/tar_unpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@
import sys
import tarfile
import os
import warnings
from builtins import UserWarning

class output(UserWarning):
pass

def custom_warning_format(message, category, filename, lineno, file=None, line=None):
formatted_message = f"{category.__name__}: {message}"
print(formatted_message, end='\n')

# 设置自定义的警告显示处理函数
warnings.showwarning = custom_warning_format

def print_log(message, category=output, stacklevel=1, source=None):
"""Logger function.
1. You cannot call print() to directly print to Octave terminal.
2. Octave package doesn't allow to make deeper Python package dir.
So use this instead."""
warnings.warn(message, category, stacklevel, source)

if len(sys.argv) < 3:
print("Usage: tar_unpack(tar_filename, destination_dir)")
Expand All @@ -34,10 +53,14 @@ def untar_file(tar_filename, destination_dir):
if not os.path.exists(destination_dir):
os.makedirs(destination_dir)

with tarfile.open(tar_filename, "r:") as tar:
tar.extractall(path=destination_dir)

print(f"File {tar_filename} has been untarred to {destination_dir}.")
try:
with tarfile.open(tar_filename, "r:") as tar:
tar.extractall(path=destination_dir)
print_log(f"File {tar_filename} has been untarred to {destination_dir}.")
return 0
except BaseException as e:
print_log(e)
return 1

if __name__ == "__main__":
untar_file(sys.argv[1], sys.argv[2])

0 comments on commit 7aaeab4

Please sign in to comment.