
    Mgx                     H   S r SSKrSSKJr  SSKJrJrJrJr   \R                  R                  \R                  R                  \5      5      r\R                  R                  \SSS5      r\" \S9\" S5      S	 5       5       r\" \S9\" S5      S
 5       5       rS rS rS rg)zThis plugin is developed for developers as its use is to create a template
based on the guidlines of the creators of the project
to ecourage people to experiment with jarvis's plugins.
    N)Fore)pluginrequireMACOSLINUXz..zcustom/)platformzcreate pluginc                 \   US:X  a1  U R                  S[        R                  5        U R                  5       nOUn [	        U5      nSn [
        R                  R                  [        U-   S-   5      (       d8  [
        R                  R                  [        S-   U-   S-   5      (       a  U(       d  U R                  SU-   S-   [        R                  5        U R                  S[        R                  5        U R                  5       nUS	:X  a  S
n[	        U5      n[
        R                  R                  [        U-   S-   5      (       a  M  [
        R                  R                  [        S-   U-   S-   5      (       a	  U(       d  M  U(       d   [        [        U5      n[
        R                  " U5        [        U5      (       aL  U R                  US-   S-   [        R                  5        S[        -   U-   S-   n[
        R                  " U5        g U R                  S[        R                  5        g g )N 'Please insert the name of your plugin: F.py/A plugin with the name '' already exists>Please choose another name or type 'exit' for obvious results:exitT .py created successfully inside Jarvis/customzopen 5Something went wrong in the creation of the plugin :(sayr   REDinputformat_filenameospathisfileCUSTOM_PLUGINS_PATHPLUGINS_PATHCYANcreate_templatesystemfile_existsjarvissnamefilenamer   new_namestrings          C/Users/admin/workspace/ai/Jarvis/jarviscli/plugins/create_plugin.pycreate_plugin_MACr+      s   
 	Bw

<dhhG||~ t$HD 77>>-85@AA77>>,,x7%?@@

-8%&'+xx	1

 *+/99	6 <<>vD"8, 77>>-85@AA77>>,,x7%?@@t 	 !!4h?
		&x  JJx"DD&'(,		322X=EFIIfJJNxx!     c                 \   US:X  a1  U R                  S[        R                  5        U R                  5       nOUn [	        U5      nSn [
        R                  R                  [        U-   S-   5      (       d8  [
        R                  R                  [        S-   U-   S-   5      (       a  U(       d  U R                  SU-   S-   [        R                  5        U R                  S[        R                  5        U R                  5       nUS	:X  a  S
n[	        U5      n[
        R                  R                  [        U-   S-   5      (       a  M  [
        R                  R                  [        S-   U-   S-   5      (       a	  U(       d  M  U(       d   [        [        U5      n[
        R                  " U5        [        U5      (       aL  U R                  US-   S-   [        R                  5        S[        -   U-   S-   n[
        R                  " U5        g U R                  S[        R                  5        g g )Nr
   r   Fr   r   r   r   r   r   Tr   r   z	xdg-open r   r   r#   s          r*   create_plugin_LINUXr.   B   s   
 	Bw

<dhhG||~ t$HD 77>>-85@AA77>>,,x7%?@@

-8%&'+xx	1

 *+/99	6 <<>vD"8, 77>>-85@AA77>>,,x7%?@@ 	 !!4h?
		&x  JJx"DD&'(,		3 #66AEIFIIfJJNxx! r,   c                 b    [         R                  R                  [        U -   S-   5      (       a  gg)zcThis method is used to check if a file with
the name "filename" exists in the Jarvis/custom folder
r   TF)r   r   r   r   )r'   s    r*   r"   r"   q   s(     
ww~~)H4u<==r,   c                    ^ SSK nSUR                  < UR                  < 3mSR                  U4S jU  5       5      nUR	                  SS5      nU$ )a  Take a string and return a valid filename constructed from the string.
Uses a whitelist approach: any characters not present in valid_chars are
removed. Also spaces are replaced with underscores.

Note: this method may produce invalid filenames such as ``, `.` or `..`
When I use this method I prepend a date string like '2009_01_15_19_46_32_'
and append a file extension like '.txt', so I avoid the potential of using
an invalid filename.
r   Nz-_.() r
   c              3   6   >#    U  H  oT;   d  M
  Uv   M     g 7f)N ).0cvalid_charss     r*   	<genexpr>"format_filename.<locals>.<genexpr>   s     ;$Q{*:qq$s   		 _)r)   ascii_lettersdigitsjoinreplace)r&   r)   r'   r5   s      @r*   r   r   {   sG     "("6"6FKww;$;;HS)HOr,   c                 "    SU -   S-   U-   S-   nU$ )zThis method is used to format the template of the plugin
that is being created given the filename and the path
in which it will be stored.
zcd z
            cat >> a  .py << EOL
# All plugins should inherite from this library
from plugin import plugin

# This is the standard form of a plugin for jarvis

# Anytime you make a change REMEMBER TO RESTART Jarvis

# You can run it through jarvis by the name
# in the @plugin tag.


@plugin("my plugin")
def my_plugin(jarvis, s):

    # Prints 'This is my new plugin!'
    jarvis.say("This is my new plugin!")

# For more info about plugin development visit:
# https://github.com/sukeesh/Jarvis/blob/master/doc/PLUGINS.md
EOLr2   )r   r'   templates      r*   r    r       s1    
 4 # !"%H. Or,   )__doc__r   coloramar   r   r   r   r   r   dirnameabspath__file__r   r<   r   r+   r.   r"   r   r    r2   r,   r*   <module>rE      s   
 
  0 0 wwrwwx89ggll<tYG  	%+!  +!^ 	%*!  *!Z$r,   