Repository: weecology/retriever

Issue:
Improve script creation platform to detect already existing data packages before we duplicate them
**Easy:**

Before a user/developer spends time on the data, we should be able to tell if we already have that data in the retriever. 
Once the user gets the exact url of the data source. We should run a command to check all the urls in the scripts instance if the url exists.

**How to solve:**
User has a url of a data source, i,e. `new-data-source-url`
Use already available functions like 
[def SCRIPT_LIST(): ](https://github.com/weecology/retriever/blob/bb06180a030d34eafa2e1ea13b74a3719df827e1/retriever/lib/scripts.py#L108)
```
 for script in SCRIPT_LIST()
      check if the script resource url equals new-data-source-url
      if so, register any match
tell the user that we have found some matches in script name
or data not in the retriever yet
```


Sample usage should be something like
`retriever autocreate --check "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/bezdekIris.data" `
Data package Iris exist already

Note: Use [get opts](https://github.com/weecology/retriever/blob/main/retriever/lib/get_opts.py) to add the `--check`  for `retriever autocreate --check` 


Discussion:
I have tried working on this issue, how do I check if my implementation is correct?
Could you open a pull request. I could look through what you have done.
The design of the solution is almost as you have done but instead of checking for the `script ==dataset`, we want to check if the script object has an attribute 'url` and if that url is the same as what we have passed. 
@henrykironde sir, can you please look into this?
@dassaniansh, I commented on the Pull request. I need to seem some commands that you used to test this.



Resolving patch:
diff --git a/retriever/__main__.py b/retriever/__main__.py
--- a/retriever/__main__.py
+++ b/retriever/__main__.py
@@ -86,7 +86,6 @@ def main():
             f = open(args.filename, 'w')
             f.write(sample_script)
             f.close()
-
             return
 
         if args.command == 'reset':
@@ -94,6 +93,22 @@ def main():
             return
 
         if args.command == 'autocreate':
+            if args.c:
+                url = args.path
+                script_list = SCRIPT_LIST()
+                flag = 0
+
+                for script in script_list:
+                    for dataset in script.tables:
+                        if script.tables[dataset].url == url:
+                            flag = 1
+                            break
+
+                if flag == 1:
+                    print("File already exist in dataset " + str(script.name))
+                else:
+                    print("Dataset is not avaliable, Please download")
+                return
             if sum([args.f, args.d]) == 1:
                 file_flag = bool(args.f)
                 create_package(args.path, args.dt, file_flag, args.o, args.skip_lines,
diff --git a/retriever/lib/get_opts.py b/retriever/lib/get_opts.py
--- a/retriever/lib/get_opts.py
+++ b/retriever/lib/get_opts.py
@@ -143,6 +143,7 @@
                                help='write scripts out to a designated directory',
                                nargs='?',
                                const='')
+autocreate_parser.add_argument('-c', help='turn files into scripts', action='store_true')
 autocreate_parser.add_argument('--skip-lines',
                                help='skip a set number of lines before processing data',
                                nargs=1,


Test patch: