Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,41 @@

name: Python package

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
on: [push, pull_request]

jobs:
test:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
build:

runs-on: ubuntu-20.04
runs-on: ubuntu-20.04 # 3.6 is not supported by Ubuntu 22.04
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
test:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] # testcontainers is not supported on <3.9
needs: build
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -34,4 +54,4 @@ jobs:
run: docker image prune -af
- name: Test with pytest
run: |
python -m unittest discover -v -s test -p "test*.py"
python -m unittest discover -v -s test -p "test*.py"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
*.pyc
build/
*.egg-info/
.vscode
.vscode
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.0
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ A python client library for ChannelFinder.

The python channelfinder client library can be configured by setting up a `channelfinderapi.conf` file in the following locations

`/etc/channelfinderapi.conf`
`~/.channelfinderapi.conf`
`channelfinderapi.conf`
`/etc/channelfinderapi.conf`
`~/.channelfinderapi.conf`
`channelfinderapi.conf`

The example preferences:
The example preferences:

```
cat ~/channelfinderapi.conf
[DEFAULT]
BaseURL=http://localhost:8080/ChannelFinder
username=MyUserName
password=MyPassword
cat ~/channelfinderapi.conf
[DEFAULT]
BaseURL=http://localhost:8080/ChannelFinder
username=MyUserName
password=MyPassword
```

## Development

To install with dependancies for testing.
Expand All @@ -38,4 +38,4 @@ To run all tests:

```bash
python -m unittest discover -v -s test -p "test*.py"
```
```
21 changes: 8 additions & 13 deletions channelfinder/CFDataTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,14 @@
"""


from ._conf import PYTHON3

if PYTHON3:
# cmp function is gone in Python 3.
# Define for backward compatibility
def cmp(a, b):
return (a > b) - (a < b)
def cmp(a, b):
return (a > b) - (a < b)


class Channel(object):
# TODO
# updated the properties data structure by splitting it into 2 dict

# All the attributes are private and read only in an attempt to make the channel object immutable
Name = property(lambda self: self.__Name)
Owner = property(lambda self: self.__Owner)
Expand All @@ -42,7 +37,7 @@ def __init__(self, name, owner, properties=None, tags=None):
self.__Owner = str(owner).strip()
self.Properties = properties
self.Tags = tags

## TODO don't recreate the dictionary with every get
def getProperties(self):
"""
Expand Down Expand Up @@ -85,10 +80,10 @@ def __init__(self, name, owner, value=None):
self.Value = value
if self.Value:
str(value).strip()
def __cmp__(self, *arg, **kwargs):

def __cmp__(self, *arg, **kwargs):
if arg[0] is None:
return 1
return 1
return cmp((self.Name, self.Value), (arg[0].Name, arg[0].Value))


Expand All @@ -99,7 +94,7 @@ def __init__(self, name, owner):
"""
self.Name = str(name).strip()
self.Owner = str(owner).strip()

def __cmp__(self, *arg, **kwargs):
if arg[0] is None:
return 1
Expand Down
Loading
Loading