summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-03-09 15:11:17 +0000
committerCoprDistGit <infra@openeuler.org>2023-03-09 15:11:17 +0000
commita39affae3abe8e7bbe8ce9710449acae3b9c02a3 (patch)
tree709961bf98efd49751431e3e65aee5fac659492a
parente369762119a74978026b620552a23ec9c48dc6e1 (diff)
automatic import of python-plugnplay
-rw-r--r--.gitignore1
-rw-r--r--python-plugnplay.spec324
-rw-r--r--sources1
3 files changed, 326 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..080ee36 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/plugnplay-0.5.4.tar.gz
diff --git a/python-plugnplay.spec b/python-plugnplay.spec
new file mode 100644
index 0000000..eb09683
--- /dev/null
+++ b/python-plugnplay.spec
@@ -0,0 +1,324 @@
+%global _empty_manifest_terminate_build 0
+Name: python-plugnplay
+Version: 0.5.4
+Release: 1
+Summary: A Generic plug-in system for python
+License: GPLv2
+URL: http://github.com/daltonmatos/plugnplay
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/7e/b1/46bf913524b93361a4749da565204a924feeceb05c06e73830ad4c90c527/plugnplay-0.5.4.tar.gz
+BuildArch: noarch
+
+
+%description
+Plug n' Play
+************
+
+Plug n' PLay (PnP) is a Generic plug-in system inspired by Trac's (http://trac.edgewall.org)
+internal component management. With PnP you can turn any program into a pluggable software very easily.
+
+You just have to define the Interfaces and let others implement them. When your code is running
+you can dynamically retrieve who are the classes that implement a certain Interface, and call
+the specific methods.
+
+A simple example
+****************
+
+Think this way: You have e very simple program that just copy files around.
+
+Say you want to check if the copy was OK by calculating the MD5 hash of the
+two files (the original and the copy). You can do this implementing the MD5 check
+inside your main code, that's OK too, but when you need to add another check
+(e.g. calculate the SHA-1 of the files) you will have to modify your code so
+it can call two methods, the MD5 checker and the SHA-1 checker.
+
+With PnP you write only the main piece of the program, the part that does only the copying,
+and the hash checkers you can implement whenever you want, *without* any modification
+to the main code.
+
+PnP is roughly a implementation of the Observer pattern (http://en.wikipedia.org/wiki/Observer_pattern).
+
+The code for this example
+*************************
+
+Ok, too much talk, now some code. A pseudo-code to the example above would be:
+
+::
+
+ class CopyListener(Interface):
+ def copy_finished(self, original_file, new_file):
+ pass
+
+
+
+The main code would be:
+
+::
+
+ PnP.load_plugins("/some/path/with/python/files") # egg files in the future?.
+ copy_file(file1, file2)
+
+ # Would return all python classes that
+ # implement CopyListerner interface
+ copy_listeners = CopyListener.implementors()
+
+ # Call each of the listeners telling the copy finished
+ for listener in copy_listeners:
+ listener.copy_finished(file1, file2)
+
+
+And an example of one such observer would be:
+
+::
+
+ from myproject.interfaces import CopyListener
+
+ class MD5Check(Plugin):
+ implements = [CopyListener,]
+
+ def copy_finished(self, file1, file2):
+ md5_1 = hash.md5(file1.read()).hexdigest()
+ md5_2 = hash.md5(file2.read()).hexdigest()
+ if md5_1 is not md5_2:
+ # Do something very useful! =)
+
+
+Conclusion
+**********
+
+Did you like this project? Very nice, so help me write it! Fork the repo and
+send me some pull requests! Or talk to me directly if you have some great ideas to implement!
+
+
+Thanks,
+
+Dalton Barreto
+
+
+
+
+%package -n python3-plugnplay
+Summary: A Generic plug-in system for python
+Provides: python-plugnplay
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-plugnplay
+Plug n' Play
+************
+
+Plug n' PLay (PnP) is a Generic plug-in system inspired by Trac's (http://trac.edgewall.org)
+internal component management. With PnP you can turn any program into a pluggable software very easily.
+
+You just have to define the Interfaces and let others implement them. When your code is running
+you can dynamically retrieve who are the classes that implement a certain Interface, and call
+the specific methods.
+
+A simple example
+****************
+
+Think this way: You have e very simple program that just copy files around.
+
+Say you want to check if the copy was OK by calculating the MD5 hash of the
+two files (the original and the copy). You can do this implementing the MD5 check
+inside your main code, that's OK too, but when you need to add another check
+(e.g. calculate the SHA-1 of the files) you will have to modify your code so
+it can call two methods, the MD5 checker and the SHA-1 checker.
+
+With PnP you write only the main piece of the program, the part that does only the copying,
+and the hash checkers you can implement whenever you want, *without* any modification
+to the main code.
+
+PnP is roughly a implementation of the Observer pattern (http://en.wikipedia.org/wiki/Observer_pattern).
+
+The code for this example
+*************************
+
+Ok, too much talk, now some code. A pseudo-code to the example above would be:
+
+::
+
+ class CopyListener(Interface):
+ def copy_finished(self, original_file, new_file):
+ pass
+
+
+
+The main code would be:
+
+::
+
+ PnP.load_plugins("/some/path/with/python/files") # egg files in the future?.
+ copy_file(file1, file2)
+
+ # Would return all python classes that
+ # implement CopyListerner interface
+ copy_listeners = CopyListener.implementors()
+
+ # Call each of the listeners telling the copy finished
+ for listener in copy_listeners:
+ listener.copy_finished(file1, file2)
+
+
+And an example of one such observer would be:
+
+::
+
+ from myproject.interfaces import CopyListener
+
+ class MD5Check(Plugin):
+ implements = [CopyListener,]
+
+ def copy_finished(self, file1, file2):
+ md5_1 = hash.md5(file1.read()).hexdigest()
+ md5_2 = hash.md5(file2.read()).hexdigest()
+ if md5_1 is not md5_2:
+ # Do something very useful! =)
+
+
+Conclusion
+**********
+
+Did you like this project? Very nice, so help me write it! Fork the repo and
+send me some pull requests! Or talk to me directly if you have some great ideas to implement!
+
+
+Thanks,
+
+Dalton Barreto
+
+
+
+
+%package help
+Summary: Development documents and examples for plugnplay
+Provides: python3-plugnplay-doc
+%description help
+Plug n' Play
+************
+
+Plug n' PLay (PnP) is a Generic plug-in system inspired by Trac's (http://trac.edgewall.org)
+internal component management. With PnP you can turn any program into a pluggable software very easily.
+
+You just have to define the Interfaces and let others implement them. When your code is running
+you can dynamically retrieve who are the classes that implement a certain Interface, and call
+the specific methods.
+
+A simple example
+****************
+
+Think this way: You have e very simple program that just copy files around.
+
+Say you want to check if the copy was OK by calculating the MD5 hash of the
+two files (the original and the copy). You can do this implementing the MD5 check
+inside your main code, that's OK too, but when you need to add another check
+(e.g. calculate the SHA-1 of the files) you will have to modify your code so
+it can call two methods, the MD5 checker and the SHA-1 checker.
+
+With PnP you write only the main piece of the program, the part that does only the copying,
+and the hash checkers you can implement whenever you want, *without* any modification
+to the main code.
+
+PnP is roughly a implementation of the Observer pattern (http://en.wikipedia.org/wiki/Observer_pattern).
+
+The code for this example
+*************************
+
+Ok, too much talk, now some code. A pseudo-code to the example above would be:
+
+::
+
+ class CopyListener(Interface):
+ def copy_finished(self, original_file, new_file):
+ pass
+
+
+
+The main code would be:
+
+::
+
+ PnP.load_plugins("/some/path/with/python/files") # egg files in the future?.
+ copy_file(file1, file2)
+
+ # Would return all python classes that
+ # implement CopyListerner interface
+ copy_listeners = CopyListener.implementors()
+
+ # Call each of the listeners telling the copy finished
+ for listener in copy_listeners:
+ listener.copy_finished(file1, file2)
+
+
+And an example of one such observer would be:
+
+::
+
+ from myproject.interfaces import CopyListener
+
+ class MD5Check(Plugin):
+ implements = [CopyListener,]
+
+ def copy_finished(self, file1, file2):
+ md5_1 = hash.md5(file1.read()).hexdigest()
+ md5_2 = hash.md5(file2.read()).hexdigest()
+ if md5_1 is not md5_2:
+ # Do something very useful! =)
+
+
+Conclusion
+**********
+
+Did you like this project? Very nice, so help me write it! Fork the repo and
+send me some pull requests! Or talk to me directly if you have some great ideas to implement!
+
+
+Thanks,
+
+Dalton Barreto
+
+
+
+
+%prep
+%autosetup -n plugnplay-0.5.4
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-plugnplay -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Thu Mar 09 2023 Python_Bot <Python_Bot@openeuler.org> - 0.5.4-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..c882590
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+34f9b434198f9cf210a908f83f43c51b plugnplay-0.5.4.tar.gz