Explorar el Código

Added nico execution module

nee2c hace 4 años
padre
commit
c6890ad4a3
Se han modificado 1 ficheros con 54 adiciones y 0 borrados
  1. 54 0
      salt/_modules/nico.py

+ 54 - 0
salt/_modules/nico.py

@@ -0,0 +1,54 @@
+
+__func_alias__ = {
+    "list_": "list",
+}
+
+def __virtual__():
+    return True
+
+
+def _genprimes():
+    """
+    genarator of primes
+    """
+    prms = {}
+    n = 2
+    while True:
+        if all([n % pr for pr in prms]):
+            yield n
+            prms[n] = n**2
+        else:
+            for key, val in [(x,y) for x, y in prms.items() if y == n]:
+                prms[key] += key
+        n += 1
+
+def com(num):
+    """
+    Function that finds components primes of a given number
+    """
+    comp = []
+    for pr in _genprimes():
+        while not num % pr:
+            comp.append(pr)
+            num /= pr
+            if num == 1:
+                return comp
+
+def fib(num):
+    """
+    Gives the nth fibonacci number
+    """
+    return __salt__["test.fib"](num)
+
+
+def list_(num):
+    """
+    List all prime numbers below given number
+    """
+    x = []
+    for y in _genprimes():
+        if y < num:
+            x.append(y)
+        else:
+            break
+    return x