[Ann] managesieve v0.8 released

2024-03-18 Thread Hartmut Goebel via Python-list

Announcing:

 managesieve 0.8

    RFC-5804 Manage Sieve client library for remotely managing Sieve 
scripts,

    including an user application (the interactive 'sieveshell').

:Homepage: https://managesieve.readthedocs.io/
:Author:   Hartmut Goebel 
:License:
  - for the managesieve module: Python-Software-Foundation-like License
  - for sieveshell and test suite: GNU Public Licence v3 (GPLv3)

:Quick Installation:
    pip install -U managesieve

:Tarballs:  https://pypi.org/project/managesieve/#files


What is managesieve?
-

A ManageSieve client library for remotely managing Sieve scripts,
including an user application (the interactive 'sieveshell').

Sieve scripts allow users to filter incoming email on the mail server
and are supported by many IMAP servers.
The ManageSieve protocol allows managing Sieve scripts on a remote
mail server. These servers are commonly sealed so users cannot log
into them, yet users must be able to update their scripts on them.
This is what for the "ManageSieve" protocol is. For more information
about the ManageSieve protocol see `RFC 5804
`_.

This module allows accessing a Sieve-Server for managing Sieve scripts
there. It is accompanied by a simple yet functional user application
'sieveshell'.


Changes since last release
---

* Now supports Python 3.6 to 3.12.

:managesieve:
   - Add support for the UNAUTHENTICATE command.
   - Add a socket timeout parameter.
   - Add support for IPv6.
   - Allow disabling certificate verification.
   - Follow the 'Logging for a Library' guideline.
   - BREAKING: Rearrange DEBUG logging levels to be more reasonable.
 See `docs/Logging.rst` for details.

:sieveshell:
   - Add option '--no-tls-verify'.
   - Improve error message if TLS certificate verification fails.
   - Keep line-endings on file IO.
   - Remove temporary file on successful edit, too.
   - Fix: Pass to sieve.login() the Authorization ID

:general:
   - Add support for Python 3.12.
   - Improve testing, add a tox.ini file and add CI/CD.
   - Fix SPDX license identifier.
   - Fix several typos.
   - Lint all the code.
   - Remove unused code.

--
Regards
Hartmut Goebel

| Hartmut Goebel  | h.goe...@crazy-compilers.com   |
| www.crazy-compilers.com | compilers which you thought are impossible |

--
https://mail.python.org/mailman/listinfo/python-list


Re: Configuring an object via a dictionary

2024-03-18 Thread Anders Munch via Python-list
dn wrote:
>Loris Bennett wrote:
>> However, with a view to asking forgiveness rather than
>> permission, is there some simple way just to assign the dictionary
>> elements which do in fact exist to self-variables?
>
>Assuming config is a dict:
>
>   self.__dict__.update( config )

Here's another approach:

config_defaults = dict(
 server_host='localhost',
 server_port=443,
# etc.
)
...
def __init__(self, config):
self.conf = types.SimpleNamespace(**{**config_defaults, **config})

This gives you defaults, simple attribute access, and avoids the risk of name 
collisions that you get when updating __dict__.

Using a dataclass may be better:

@dataclasses.dataclass
class Settings:
 group_base : str
 server_host : str = 'localhost'
 server_port : int = 443
...
def __init__(self, config):
self.conf = Settings(**config)

regards, Anders

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Configuring an object via a dictionary

2024-03-18 Thread Tobiah via Python-list

On 3/15/24 02:30, Loris Bennett wrote:

Hi,

I am initialising an object via the following:

 def __init__(self, config):

 self.connection = None

 self.source_name = config['source_name']
 self.server_host = config['server_host']



However, with a view to asking forgiveness rather than
permission, is there some simple way just to assign the dictionary
elements which do in fact exist to self-variables?


class Foo():

def __init__(self, config):

for key, val in config.iteritems():
setattr(self, key, val)

f = Foo({'cat': 'dog'})

print(f.cat)

(outputs 'dog')

--
https://mail.python.org/mailman/listinfo/python-list


Re: Configuring an object via a dictionary

2024-03-18 Thread Tobiah via Python-list

I should mention that I wanted to answer your question,
but I wouldn't actually do this.  I'd rather opt for
your self.config = config solution.  The config options
should have their own namespace.

I don't mind at all referencing foo.config['option'],
or you could make foo.config an object by itself so
you can do foo.config.option.  You'd fill it's attributes
in the same way I suggested for your main object.




--
https://mail.python.org/mailman/listinfo/python-list


Re: Configuring an object via a dictionary

2024-03-18 Thread Loris Bennett via Python-list
Tobiah  writes:

> I should mention that I wanted to answer your question,
> but I wouldn't actually do this.  I'd rather opt for
> your self.config = config solution.  The config options
> should have their own namespace.
>
> I don't mind at all referencing foo.config['option'],
> or you could make foo.config an object by itself so
> you can do foo.config.option.  You'd fill it's attributes
> in the same way I suggested for your main object.

Thanks for the thoughts.  I'll go for self.config = config after
all, since, as you say, the clutter caused by the referencing is not
that significant.

Cheers,

Loris

-- 
This signature is currently under constuction.
-- 
https://mail.python.org/mailman/listinfo/python-list