问:
Using Poetry with PyEnv and having Python version issues
I'm working on WSL2 Ubuntu. I've been taking a course in backend API development using Fastapi. My Ubuntu default python is 3.8 I believe. I'm trying to use python 3.10.0 for my development. I've done the following:

pyenv install 3.10.0

cd to my project folder and pyenv local 3.10.0 (creates .python-version file containing 3.10.0)

poetry shell (this creates a .venv folder and all dependencies are added there during development). Bash Prompt has (.venv) in it.

python --version shows 3.10.0 as current version

My problem is that when I look into the .venv/bin file, all of the symbolic links show python 3.8.

```<code>drwxr-xr-x 2 mryan mryan 4096 Feb  1 23:12 .
drwxr-xr-x 4 mryan mryan 4096 Feb  1 23:12 ..
-rw-r--r-- 1 mryan mryan 2152 Feb  1 23:12 activate
-rw-r--r-- 1 mryan mryan 1444 Feb  1 23:12 activate.csh
-rw-r--r-- 1 mryan mryan 3033 Feb  1 23:12 activate.fish
-rw-r--r-- 1 mryan mryan 1303 Feb  1 23:12 activate.nu
-rw-r--r-- 1 mryan mryan 1754 Feb  1 23:12 activate.ps1
-rw-r--r-- 1 mryan mryan 1199 Feb  1 23:12 activate_this.py
-rw-r--r-- 1 mryan mryan  333 Feb  1 23:12 deactivate.nu
-rwxr-xr-x 1 mryan mryan  249 Feb  1 23:12 pip
-rwxr-xr-x 1 mryan mryan  249 Feb  1 23:12 pip-3.8
-rwxr-xr-x 1 mryan mryan  249 Feb  1 23:12 pip3
-rwxr-xr-x 1 mryan mryan  249 Feb  1 23:12 pip3.8
lrwxrwxrwx 1 mryan mryan   18 Feb  1 23:12 python -> /usr/bin/python3.8
lrwxrwxrwx 1 mryan mryan    6 Feb  1 23:12 python3 -> python
lrwxrwxrwx 1 mryan mryan    6 Feb  1 23:12 python3.8 -> python
-rwxr-xr-x 1 mryan mryan  236 Feb  1 23:12 wheel
-rwxr-xr-x 1 mryan mryan  236 Feb  1 23:12 wheel-3.8
-rwxr-xr-x 1 mryan mryan  236 Feb  1 23:12 wheel3
-rwxr-xr-x 1 mryan mryan  236 Feb  1 23:12 wheel3.8
</code>```

When I try using the command poetry env use 3.10.0 I get the following:

```<code>(.venv) mryan ~/python/fastapi1/.venv/bin $poetry env use 3.10.0
/bin/sh: 1: python3.10: not found

  EnvCommandError

  Command python3.10 -c "import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))" errored with the following return code 127, and output:

  at ~/.local/share/pypoetry/venv/lib/python3.8/site-packages/poetry/utils/env.py:378 in activate
       374│                     shell=True,
       375│                 )
       376│             )
       377│         except CalledProcessError as e:
    →  378│             raise EnvCommandError(e)
       379│
       380│         python_version = Version.parse(python_version.strip())
       381│         minor = "{}.{}".format(python_version.major, python_version.minor)
       382│         patch = python_version.text
(.venv) mryan ~/python/fastapi1/.venv/bin $python3.10
python3.10: command not found
</code>```

What am I doing wrong here? I feel I'm missing something significant here. I've been through a zillion web pages on poetry and virtual environments.

答:
I'm able to replicate your exact error using these commands:

poetry new test-project

cd test-project/

poetry env use 3.10

Result in the exact same error you are getting. However, this works for me:

poetry new test-project

cd test-project/

pyenv local 3.10

poetry env use 3.10

Following these commands my poetry will create a .venv inside the project's folder successfully. By the way, you'll have to edit the pyproject.toml file manually, because that doesn't change using this method.

If this doesn't work I suspect something went wrong while adding pyenv to your PATH. In that case you could try resetting your 'dot-files' (.bashrc, .bash_profile and/or .profile) and add pyenv again using these commands from the pyenv github:

```<code># the sed invocation inserts the lines at the start of the file
# after any initial comment lines
sed -Ei -e '/^([^#]|$)/ {a \
export PYENV_ROOT="$HOME/.pyenv"
a \
export PATH="$PYENV_ROOT/bin:$PATH"
a \
' -e ':a' -e '$!{n;ba};}' ~/.profile
echo 'eval "$(pyenv init --path)"' >>~/.profile

echo 'eval "$(pyenv init -)"' >> ~/.bashrc
</code>```

Body:
I'm working on WSL2 Ubuntu. I've been taking a course in backend API development using Fastapi. My Ubuntu default python is 3.8 I believe. I'm trying to use python 3.10.0 for my development. I've done the following:

pyenv install 3.10.0

cd to my project folder and pyenv local 3.10.0 (creates .python-version file containing 3.10.0)

poetry shell (this creates a .venv folder and all dependencies are added there during development). Bash Prompt has (.venv) in it.

python --version shows 3.10.0 as current version

My problem is that when I look into the .venv/bin file, all of the symbolic links show python 3.8.

drwxr-xr-x 2 mryan mryan 4096 Feb  1 23:12 .
drwxr-xr-x 4 mryan mryan 4096 Feb  1 23:12 ..
-rw-r--r-- 1 mryan mryan 2152 Feb  1 23:12 activate
-rw-r--r-- 1 mryan mryan 1444 Feb  1 23:12 activate.csh
-rw-r--r-- 1 mryan mryan 3033 Feb  1 23:12 activate.fish
-rw-r--r-- 1 mryan mryan 1303 Feb  1 23:12 activate.nu
-rw-r--r-- 1 mryan mryan 1754 Feb  1 23:12 activate.ps1
-rw-r--r-- 1 mryan mryan 1199 Feb  1 23:12 activate_this.py
-rw-r--r-- 1 mryan mryan  333 Feb  1 23:12 deactivate.nu
-rwxr-xr-x 1 mryan mryan  249 Feb  1 23:12 pip
-rwxr-xr-x 1 mryan mryan  249 Feb  1 23:12 pip-3.8
-rwxr-xr-x 1 mryan mryan  249 Feb  1 23:12 pip3
-rwxr-xr-x 1 mryan mryan  249 Feb  1 23:12 pip3.8
lrwxrwxrwx 1 mryan mryan   18 Feb  1 23:12 python -> /usr/bin/python3.8
lrwxrwxrwx 1 mryan mryan    6 Feb  1 23:12 python3 -> python
lrwxrwxrwx 1 mryan mryan    6 Feb  1 23:12 python3.8 -> python
-rwxr-xr-x 1 mryan mryan  236 Feb  1 23:12 wheel
-rwxr-xr-x 1 mryan mryan  236 Feb  1 23:12 wheel-3.8
-rwxr-xr-x 1 mryan mryan  236 Feb  1 23:12 wheel3
-rwxr-xr-x 1 mryan mryan  236 Feb  1 23:12 wheel3.8

When I try using the command poetry env use 3.10.0 I get the following:

(.venv) mryan ~/python/fastapi1/.venv/bin $poetry env use 3.10.0
/bin/sh: 1: python3.10: not found

  EnvCommandError

  Command python3.10 -c "import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))" errored with the following return code 127, and output:

  at ~/.local/share/pypoetry/venv/lib/python3.8/site-packages/poetry/utils/env.py:378 in activate
       374│                     shell=True,
       375│                 )
       376│             )
       377│         except CalledProcessError as e:
    →  378│             raise EnvCommandError(e)
       379│
       380│         python_version = Version.parse(python_version.strip())
       381│         minor = "{}.{}".format(python_version.major, python_version.minor)
       382│         patch = python_version.text
(.venv) mryan ~/python/fastapi1/.venv/bin $python3.10
python3.10: command not found

What am I doing wrong here? I feel I'm missing something significant here. I've been through a zillion web pages on poetry and virtual environments.

Body:
I'm able to replicate your exact error using these commands:

poetry new test-project

cd test-project/

poetry env use 3.10

Result in the exact same error you are getting. However, this works for me:

poetry new test-project

cd test-project/

pyenv local 3.10

poetry env use 3.10

Following these commands my poetry will create a .venv inside the project's folder successfully. By the way, you'll have to edit the pyproject.toml file manually, because that doesn't change using this method.

If this doesn't work I suspect something went wrong while adding pyenv to your PATH. In that case you could try resetting your 'dot-files' (.bashrc, .bash_profile and/or .profile) and add pyenv again using these commands from the pyenv github:

# the sed invocation inserts the lines at the start of the file
# after any initial comment lines
sed -Ei -e '/^([^#]|$)/ {a \
export PYENV_ROOT="$HOME/.pyenv"
a \
export PATH="$PYENV_ROOT/bin:$PATH"
a \
' -e ':a' -e '$!{n;ba};}' ~/.profile
echo 'eval "$(pyenv init --path)"' >>~/.profile

echo 'eval "$(pyenv init -)"' >> ~/.bashrc


来源: stackexchange

问:
How to I traverse/loop through a tree of arrays?
I have my tree which a want to traverse through, each subtree might have different length:

const Tree = [
  {
    data: true,
    subTrees: [{
      data: true, subTrees: [{ data: true, subTrees: [] }]
    }]
  },
  {
    data: true,
    subTrees: [{
      data: true, subTrees: []
    }]
  },
  {
    data: true,
    subTrees: [{
      data: true, subTrees: [{ data: true, subTrees: [{ data: true, subTrees: [] }] }]
    }]
  },
  {
    data: true,
    subTrees: [{
      data: true, subTrees: [{ data: true, subTrees: [] }]
    }]
  }
]

```
<p>How do I loop through each and every subTree so I can access the data in each node?</p>
<p>This is what I have now:</p>
<pre class="lang-js prettyprint-override"><code>
function traverseTree(currentTree) {

  for (let i = 0; i < currentTree.length; i++) {

    // do something

    traverseTree(currentTree[i])

  }

}

</code>```

答:
you can use it:</p>
```<code>const traverseTree = (arr) => {
    arr.forEach(el => {
        // do something
        traverseTree(el.subTrees);
    });
};

traverseTree(Tree);
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I have my tree which a want to traverse through, each subtree might have different length:

const Tree = [
  {
    data: true,
    subTrees: [{
      data: true, subTrees: [{ data: true, subTrees: [] }]
    }]
  },
  {
    data: true,
    subTrees: [{
      data: true, subTrees: []
    }]
  },
  {
    data: true,
    subTrees: [{
      data: true, subTrees: [{ data: true, subTrees: [{ data: true, subTrees: [] }] }]
    }]
  },
  {
    data: true,
    subTrees: [{
      data: true, subTrees: [{ data: true, subTrees: [] }]
    }]
  }
]

How do I loop through each and every subTree so I can access the data in each node?

This is what I have now:

function traverseTree(currentTree) {

  for (let i = 0; i < currentTree.length; i++) {

    // do something

    traverseTree(currentTree[i])

  }

}

Body:
you can use it:

const traverseTree = (arr) => {
    arr.forEach(el => {
        // do something
        traverseTree(el.subTrees);
    });
};

traverseTree(Tree);


问:
Update old data in oracle
hi I have old data and I want to recover them .Lets say I have the following tables .

Table1:

Company
FirstName

All
Beornræd

Table2:

CompanyNames

X

Y

Z

I want to map All to all values of the table of company such that I obtain the following result.

Table1: after update

Company
FirstName

X
Beornræd

Y
Beornræd

Z
Beornræd

I there a way to update them using a query and thanks in advance.

答:
One option would be using MERGE as only a single statement such as

MERGE INTO t1
USING (SELECT * FROM t1
       UNION ALL
       SELECT t2.companynames, t1.firstname
         FROM t2, t1) tt
   ON (t1.company = tt.company)
 WHEN NOT MATCHED THEN
                      INSERT VALUES(tt.company, tt.firstname)
 WHEN MATCHED THEN
                  UPDATE SET t1.firstname = ''
                  DELETE WHERE 1 = 1
```

newly(unmatched rows for t1.company = tt.company) generated rows  are inserted, and the matched ones are deleted, where update dml is nothing but an auxiliary representation for deletion

Demo

Title: Update old data in oracle

Body:
One option would be using MERGE as only a single statement such as

MERGE INTO t1
USING (SELECT * FROM t1
       UNION ALL
       SELECT t2.companynames, t1.firstname
         FROM t2, t1) tt
   ON (t1.company = tt.company)
 WHEN NOT MATCHED THEN
                      INSERT VALUES(tt.company, tt.firstname)
 WHEN MATCHED THEN
                  UPDATE SET t1.firstname = ''
                  DELETE WHERE 1 = 1

newly(unmatched rows for t1.company = tt.company) generated rows  are inserted, and the matched ones are deleted, where update dml is nothing but an auxiliary representation for deletion

Demo


问:
aldjemy query with ManyToManyField in django model
I need some help for the following problem.

I have the following django model, it is a simple example with the use of ManyToManyField:

```<code>from django.db import models

# Create your models here.
class Publication(models.Model):
    title = models.CharField(max_length=30)

    class Meta:
        ordering = ['title']

    def __str__(self):
        return self.title

class Article(models.Model):
    headline = models.CharField(max_length=100)
    publications = models.ManyToManyField(Publication)

    class Meta:
        ordering = ['headline']

    def __str__(self):
        return self.headline
</code>```

Then, I have the following test.py file.

The first test is ok, but the second fails:

```<code>from django.test import TestCase

# Create your tests here.
from magazine.models import Publication, Article

import sqlalchemy as sa
import sqlalchemy.orm as orm

class MagazineTestCase(TestCase):
    def setUp(self):
        p1 = Publication.objects.create(title='The Python Journal')
        p2 = Publication.objects.create(title='Science News')
        p3 = Publication.objects.create(title='Science Weekly')
        a1 = Article.objects.create(headline='Django lets you build web apps easily')
        a1.publications.add(p1)
        a2 = Article.objects.create(headline='NASA uses Python')
        a2.publications.add(p1,p2)

    def test_publications(self):
        article = Article.objects.get(headline='NASA uses Python')
        print(article)

def Session():
    from aldjemy.core import get_engine
    engine = get_engine()
    _Session = orm.sessionmaker(bind=engine)
    return _Session()

session = Session()

class AldjemyTestCase(TestCase):
    def setUp(self):
        p1 = Publication.objects.create(title='The Python Journal')
        p2 = Publication.objects.create(title='Science News')
        p3 = Publication.objects.create(title='Science Weekly')
        a1 = Article.objects.create(headline='Django lets you build web apps easily')
        a1.publications.add(p1)
        a2 = Article.objects.create(headline='NASA uses Python')
        a2.publications.add(p1,p2)

    def test_publications_with_aldjemy(self):
        article = Article.sa.query().join(Article.publications).all()
        print(article)

</code>```

with the following error:

```<code>root@d6fd57086074:/app/project# ./manage.py test magazine
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
NASA uses Python
.
======================================================================
ERROR: test_publications_with_aldjemy (magazine.tests.AldjemyTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/app/project/magazine/tests.py", line 43, in test_publications_with_aldjemy
    article = Article.sa.query().join(Article.publications).all()
  File "<string>", line 2, in join
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/base.py", line 110, in _generative
    x = fn(self, *args, **kw)
  File "<string>", line 2, in join
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/base.py", line 230, in generate
    fn(self, *args[1:], **kw)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py", line 2409, in join
    joins_to_add = tuple(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py", line 2411, in <genexpr>
    coercions.expect(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/coercions.py", line 212, in expect
    return impl._implicit_coercions(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/coercions.py", line 950, in _implicit_coercions
    elif legacy and resolved._is_select_statement:
AttributeError: 'NoneType' object has no attribute '_is_select_statement'

----------------------------------------------------------------------
Ran 2 tests in 0.066s

FAILED (errors=1)
Destroying test database for alias 'default'...
</code>```

I have some issues in finding out what is the correct statement for Article.sa.query().join(Article.publications).all().
Could you please help me or give me some hints?

EDIT1

I have also tried other types of this statements such as article = Article.sa.query().join(Article.publications).filter(Pubblication.sa.title=="The Python Journal") but I am getting the same error.

答:
I have just realized there is no need to use aldjemy but I can use Django ORM (https://docs.djangoproject.com/en/4.0/topics/db/queries/):

This code works:

```<code>from django.test import TestCase

# Create your tests here.
from magazine.models import Publication, Article

class MagazineTestCase(TestCase):
    def setUp(self):
        p1 = Publication.objects.create(title='The Python Journal')
        p2 = Publication.objects.create(title='Science News')
        p3 = Publication.objects.create(title='Science Weekly')
        a1 = Article.objects.create(headline='Django lets you build web apps easily')
        a1.publications.add(p1)
        a2 = Article.objects.create(headline='NASA uses Python')
        a2.publications.add(p1,p2)

    def test_publications(self):
        article = Article.objects.get(headline='NASA uses Python')
        print(article)

class AldjemyTestCase(TestCase):
    def setUp(self):
        p1 = Publication.objects.create(title='The Python Journal')
        p2 = Publication.objects.create(title='Science News')
        p3 = Publication.objects.create(title='Science Weekly')
        a1 = Article.objects.create(headline='Django lets you build web apps easily')
        a1.publications.add(p1)
        a2 = Article.objects.create(headline='NASA uses Python')
        a2.publications.add(p1,p2)

    def test_articles(self):
        for a in Article.objects.all():
            print(a.headline)
</code>```

Body:
I need some help for the following problem.

I have the following django model, it is a simple example with the use of ManyToManyField:

from django.db import models

# Create your models here.
class Publication(models.Model):
    title = models.CharField(max_length=30)

    class Meta:
        ordering = ['title']

    def __str__(self):
        return self.title

class Article(models.Model):
    headline = models.CharField(max_length=100)
    publications = models.ManyToManyField(Publication)

    class Meta:
        ordering = ['headline']

    def __str__(self):
        return self.headline

Then, I have the following test.py file.

The first test is ok, but the second fails:

from django.test import TestCase

# Create your tests here.
from magazine.models import Publication, Article

import sqlalchemy as sa
import sqlalchemy.orm as orm

class MagazineTestCase(TestCase):
    def setUp(self):
        p1 = Publication.objects.create(title='The Python Journal')
        p2 = Publication.objects.create(title='Science News')
        p3 = Publication.objects.create(title='Science Weekly')
        a1 = Article.objects.create(headline='Django lets you build web apps easily')
        a1.publications.add(p1)
        a2 = Article.objects.create(headline='NASA uses Python')
        a2.publications.add(p1,p2)

    def test_publications(self):
        article = Article.objects.get(headline='NASA uses Python')
        print(article)

def Session():
    from aldjemy.core import get_engine
    engine = get_engine()
    _Session = orm.sessionmaker(bind=engine)
    return _Session()

session = Session()

class AldjemyTestCase(TestCase):
    def setUp(self):
        p1 = Publication.objects.create(title='The Python Journal')
        p2 = Publication.objects.create(title='Science News')
        p3 = Publication.objects.create(title='Science Weekly')
        a1 = Article.objects.create(headline='Django lets you build web apps easily')
        a1.publications.add(p1)
        a2 = Article.objects.create(headline='NASA uses Python')
        a2.publications.add(p1,p2)

    def test_publications_with_aldjemy(self):
        article = Article.sa.query().join(Article.publications).all()
        print(article)

with the following error:

root@d6fd57086074:/app/project# ./manage.py test magazine
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
NASA uses Python
.
======================================================================
ERROR: test_publications_with_aldjemy (magazine.tests.AldjemyTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/app/project/magazine/tests.py", line 43, in test_publications_with_aldjemy
    article = Article.sa.query().join(Article.publications).all()
  File "<string>", line 2, in join
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/base.py", line 110, in _generative
    x = fn(self, *args, **kw)
  File "<string>", line 2, in join
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/base.py", line 230, in generate
    fn(self, *args[1:], **kw)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py", line 2409, in join
    joins_to_add = tuple(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py", line 2411, in <genexpr>
    coercions.expect(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/coercions.py", line 212, in expect
    return impl._implicit_coercions(
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/coercions.py", line 950, in _implicit_coercions
    elif legacy and resolved._is_select_statement:
AttributeError: 'NoneType' object has no attribute '_is_select_statement'

----------------------------------------------------------------------
Ran 2 tests in 0.066s

FAILED (errors=1)
Destroying test database for alias 'default'...

I have some issues in finding out what is the correct statement for Article.sa.query().join(Article.publications).all().
Could you please help me or give me some hints?

EDIT1

I have also tried other types of this statements such as article = Article.sa.query().join(Article.publications).filter(Pubblication.sa.title=="The Python Journal") but I am getting the same error.

Body:
I have just realized there is no need to use aldjemy but I can use Django ORM (https://docs.djangoproject.com/en/4.0/topics/db/queries/):

This code works:

from django.test import TestCase

# Create your tests here.
from magazine.models import Publication, Article

class MagazineTestCase(TestCase):
    def setUp(self):
        p1 = Publication.objects.create(title='The Python Journal')
        p2 = Publication.objects.create(title='Science News')
        p3 = Publication.objects.create(title='Science Weekly')
        a1 = Article.objects.create(headline='Django lets you build web apps easily')
        a1.publications.add(p1)
        a2 = Article.objects.create(headline='NASA uses Python')
        a2.publications.add(p1,p2)

    def test_publications(self):
        article = Article.objects.get(headline='NASA uses Python')
        print(article)

class AldjemyTestCase(TestCase):
    def setUp(self):
        p1 = Publication.objects.create(title='The Python Journal')
        p2 = Publication.objects.create(title='Science News')
        p3 = Publication.objects.create(title='Science Weekly')
        a1 = Article.objects.create(headline='Django lets you build web apps easily')
        a1.publications.add(p1)
        a2 = Article.objects.create(headline='NASA uses Python')
        a2.publications.add(p1,p2)

    def test_articles(self):
        for a in Article.objects.all():
            print(a.headline)


问:
Problem in getting all urls in a page using regex ?
I have a webpage source code stored in $page and I need to extract all urls from it

the problem that some urls which are not in  tag, but in javascript codes.

for example, I have this source code that I want to extract all urls from

```<code>    Click <a style="vertical-align:middle;cursor:pointer;text-decoration:underline;color:red;" onClick="return downme('http://www.AAAAA.com/atnbc1i7b/part1.html')">

            Here</a> to go to download page

<a href="http://www.UUUU.com/register">Hi all</a>
</code>```

and I use this regex code

```<code>$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
    if(preg_match_all("/$regexp/siU", $page, $matches, PREG_SET_ORDER))
               {
                 foreach($matches as $match)
                   {
                      print_r($match)
                   }

               }
</code>```

the output will print to me just

```<code>http://www.UUUU.com/register
</code>```

but the other link

```<code>http://www.AAAAA.com/atnbc1i7b/part1.htm
</code>```

will not appear !!

Help please

thanks

答:
URL: Find in full text (protocol optional)
Matches URLs like www.domain.com and ftp.domain.com without the http: or ftp: protocol.
The final character class makes sure that if an URL is part of some text, punctuation such as a comma or full stop after the URL is not interpreted as part of the URL.</p>

```<code>$html = <<< EOF
Click <a style="vertical-align:middle;cursor:pointer;text-decoration:underline;color:red;" onClick="return downme('http://www.AAAAA.com/atnbc1i7b/part1.html')">
Here</a> to go to download page
<a href="http://www.UUUU.com/register">Hi all</a>
EOF;

preg_match_all('/\b(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)[-A-Z0-9+&@#\/%=~_|$?!:,.]*[A-Z0-9+&@#\/%=~_|$]/i', $html, $urls, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($urls[0]); $i++) {
   echo  $urls[0][$i];
}

/* echo's :
http://www.AAAAA.com/atnbc1i7b/part1.html
http://www.UUUU.com/register
*/
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a webpage source code stored in $page and I need to extract all urls from it

the problem that some urls which are not in  tag, but in javascript codes.

for example, I have this source code that I want to extract all urls from

    Click

            Here to go to download page

Hi all

and I use this regex code

$regexp = "]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
    if(preg_match_all("/$regexp/siU", $page, $matches, PREG_SET_ORDER))
               {
                 foreach($matches as $match)
                   {
                      print_r($match)
                   }

               }

the output will print to me just

http://www.UUUU.com/register

but the other link

http://www.AAAAA.com/atnbc1i7b/part1.htm

will not appear !!

Help please

thanks

Body:
URL: Find in full text (protocol optional)
Matches URLs like www.domain.com and ftp.domain.com without the http: or ftp: protocol.
The final character class makes sure that if an URL is part of some text, punctuation such as a comma or full stop after the URL is not interpreted as part of the URL.

$html = <<< EOF
Click <a style="vertical-align:middle;cursor:pointer;text-decoration:underline;color:red;" onClick="return downme('http://www.AAAAA.com/atnbc1i7b/part1.html')">
Here</a> to go to download page
<a href="http://www.UUUU.com/register">Hi all</a>
EOF;

preg_match_all('/\b(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)[-A-Z0-9+&@#\/%=~_|$?!:,.]*[A-Z0-9+&@#\/%=~_|$]/i', $html, $urls, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($urls[0]); $i++) {
   echo  $urls[0][$i];
}

/* echo's :
http://www.AAAAA.com/atnbc1i7b/part1.html
http://www.UUUU.com/register
*/


问:
Mapster Adapt from dynamic type to class<T>
I have to manage a lot of API calls to a service and all the response messages have a common structure except the "data" field which varies according to the endpoint called and whether the call was successful or not.
Looking for a way to smartly manage the whole situation I produced a satisfying solution with the use of generics and Mapster.
This is a typical response message:

    {
       "type": "send",
       "datetime": "2022-02-21",
       "correlation_id": "dc659b16-0781-4e32-ae0d-fbe737ff3215",
       "data": {
        "id": 22,
        "description": "blue t-shirt with stripes",
        "category": "t-shirt",
        "size": "XL"
       }
    }
```
<p>The data field is totally variable, sometimes it is a one-level structure, sometimes a multi-level structure, sometimes an array, sometimes a simple string and sometimes a null.
Clearly the response messages are known and depends on the called endpoint so I know what to expect when I make the call but there is a case where the structure can still change.
If the call is unsuccessful and there is an error, a 200 is still returned from the endpoint but the response is like this:</p>
<pre class="lang-json prettyprint-override"><code>    {
       "type": "error",
       "datetime": "2022-02-21",
       "correlation_id": "dc659b16-0781-4e32-ae0d-fbe737ff3215",
       "data": {
        "id": 1522,
        "description": "product code not found",
       }
    }
</code>```

Looking for an elegant and concise solution to manage all cases with a single method, I was able to find a solution:
These are my models:

    public class Response<T> where T : class
    {
        public string type { get; set; }
        public T data { get; set; } = null;
        public Error Error { get; set; } = null;
        public bool IsError => Error != null;
        public string ErrorMessage => IsError ? $"An error occurred. Error code {Error.id} - {Error.description}" : "";
    }
    public class Customer
    {
        public int customerId { get; set; }
        public string name { get; set; }
    }
    public class Supplier
    {
        public int supplierId { get; set; }
        public string company { get; set; }
    }
    public class Error
    {
        public int id { get; set; }
        public string description { get; set; }
    }
```
<p>And this is my function that manage all the deserializations:</p>
<pre class="lang-csharp prettyprint-override"><code>    private static Response<T> GetData<T>(string json) where T : class
    {
        //Deserialize the json using dynamic as T so can receive any kind of data structure
        var resp = JsonConvert.DeserializeObject<Response<dynamic>>(json);
        var ret = resp.Adapt<Response<T>>();

        if (resp.type == "error")
        {
            //Adapt the dynamic to Error property
            ret.Error = ((object)resp.data).Adapt<Error>();
            ret.data = null;
        }
        return ret;
    }
</code>```

So I call my function in this way:

    var customerData = GetData<Customer>("{\"type\":\"send\", \"data\": {\"id\":1, \"name\": \"John Ross\"}}");
    if (customerData.IsError)
        Console.WriteLine($"ERROR! {customerData.ErrorMessage}");
    else
        Console.WriteLine($"The response is OK. Customer name is {customerData.data.name}");
```

As you can see, the solution adopted is elegant and works very well.
The only problem I haven't found solution is that Mapster.Adapt doesn't fail if I try to fit the wrong json to type T.
So if I deserialize the json of the customer in the supplier class I would not notice the problem.

Is there a way in Mapster to know if the object I'm trying to adapt isn't compatible with the target type?
So I could raise an exception and my procedure would be perfect.

Here is a repo with working example
https://github.com/mmassari/MapDynamicWIthMapster

Thank you

答:
The solution you are trying to work out might seem elegant, but in reality you could be introducing a code smell which might create hard to catch bugs in the future.

You might want to reconsider using the knowledge you already have about the endpoints to deserialize the response to their correct response types. This is good practice, and it is simple to understand and maintain for both yourself and future developers.

With regards to the problematic "product code not found" responses, you could add a validation step that deserializes the JSON response to an object of type JObject which you can safely query to check for existence of known error messages.

Here is a simple example:

private static void ValidateResponse(string json)
{
    var knownErrors = new List<string>()
    {
        "Product code not found",
        "Customer does not exist",
        "Other known errors here"
    };

    var jobj = JsonConvert.DeserializeObject<JObject>(json);
    var error = jobj.SelectToken("data.description");
    if (error != null)
    {
        var errorMessage = error.Value<string>();
        if (knownErrors.Contains(errorMessage))
        {
            throw new ApplicationException(errorMessage);
        }
    }
}
```

You may want to consider trimming and normalizing casing to avoid getting thrown off by small variations in the error messages.

Body:
I have to manage a lot of API calls to a service and all the response messages have a common structure except the "data" field which varies according to the endpoint called and whether the call was successful or not.
Looking for a way to smartly manage the whole situation I produced a satisfying solution with the use of generics and Mapster.
This is a typical response message:

    {
       "type": "send",
       "datetime": "2022-02-21",
       "correlation_id": "dc659b16-0781-4e32-ae0d-fbe737ff3215",
       "data": {
        "id": 22,
        "description": "blue t-shirt with stripes",
        "category": "t-shirt",
        "size": "XL"
       }
    }

The data field is totally variable, sometimes it is a one-level structure, sometimes a multi-level structure, sometimes an array, sometimes a simple string and sometimes a null.
Clearly the response messages are known and depends on the called endpoint so I know what to expect when I make the call but there is a case where the structure can still change.
If the call is unsuccessful and there is an error, a 200 is still returned from the endpoint but the response is like this:

    {
       "type": "error",
       "datetime": "2022-02-21",
       "correlation_id": "dc659b16-0781-4e32-ae0d-fbe737ff3215",
       "data": {
        "id": 1522,
        "description": "product code not found",
       }
    }

Looking for an elegant and concise solution to manage all cases with a single method, I was able to find a solution:
These are my models:

    public class Response<T> where T : class
    {
        public string type { get; set; }
        public T data { get; set; } = null;
        public Error Error { get; set; } = null;
        public bool IsError => Error != null;
        public string ErrorMessage => IsError ? $"An error occurred. Error code {Error.id} - {Error.description}" : "";
    }
    public class Customer
    {
        public int customerId { get; set; }
        public string name { get; set; }
    }
    public class Supplier
    {
        public int supplierId { get; set; }
        public string company { get; set; }
    }
    public class Error
    {
        public int id { get; set; }
        public string description { get; set; }
    }

And this is my function that manage all the deserializations:

    private static Response<T> GetData<T>(string json) where T : class
    {
        //Deserialize the json using dynamic as T so can receive any kind of data structure
        var resp = JsonConvert.DeserializeObject<Response<dynamic>>(json);
        var ret = resp.Adapt<Response<T>>();

        if (resp.type == "error")
        {
            //Adapt the dynamic to Error property
            ret.Error = ((object)resp.data).Adapt<Error>();
            ret.data = null;
        }
        return ret;
    }

So I call my function in this way:

    var customerData = GetData<Customer>("{\"type\":\"send\", \"data\": {\"id\":1, \"name\": \"John Ross\"}}");
    if (customerData.IsError)
        Console.WriteLine($"ERROR! {customerData.ErrorMessage}");
    else
        Console.WriteLine($"The response is OK. Customer name is {customerData.data.name}");

As you can see, the solution adopted is elegant and works very well.
The only problem I haven't found solution is that Mapster.Adapt doesn't fail if I try to fit the wrong json to type T.
So if I deserialize the json of the customer in the supplier class I would not notice the problem.

Is there a way in Mapster to know if the object I'm trying to adapt isn't compatible with the target type?
So I could raise an exception and my procedure would be perfect.

Here is a repo with working example
https://github.com/mmassari/MapDynamicWIthMapster

Thank you

Body:
The solution you are trying to work out might seem elegant, but in reality you could be introducing a code smell which might create hard to catch bugs in the future.

You might want to reconsider using the knowledge you already have about the endpoints to deserialize the response to their correct response types. This is good practice, and it is simple to understand and maintain for both yourself and future developers.

With regards to the problematic "product code not found" responses, you could add a validation step that deserializes the JSON response to an object of type JObject which you can safely query to check for existence of known error messages.

Here is a simple example:

private static void ValidateResponse(string json)
{
    var knownErrors = new List<string>()
    {
        "Product code not found",
        "Customer does not exist",
        "Other known errors here"
    };

    var jobj = JsonConvert.DeserializeObject<JObject>(json);
    var error = jobj.SelectToken("data.description");
    if (error != null)
    {
        var errorMessage = error.Value<string>();
        if (knownErrors.Contains(errorMessage))
        {
            throw new ApplicationException(errorMessage);
        }
    }
}

You may want to consider trimming and normalizing casing to avoid getting thrown off by small variations in the error messages.


问:
Clearner way to wait for function to complete before continuing
First I fetch a random quote from a public api. Only AFTER I actually have a quote I want to render the page including that quote.

I am a JavaScript newbie so please bear with me if this is a stupid question.

I was struggling with waiting for the api call to return BEFORE continuing with rendering the page.
I wanted to do the following, but this doesn't work because res.render will be called before I have a quote. (note: I am using Express and Axios)

```<code>async function getRandomQuote() {
    try {
        const res = await axios.get("https://api.quotable.io/random?tags=famous-quotes")
        console.log(`${res.data.content} - ${res.data.author}`)     //This prints fine
        return res.data
    } catch(e) {
        console.log('error', e)
    }
}

app.get('/', (req, res) => {

    const quote = getRandomQuote()
    console.log(`${quote.content} - ${quote.author}`)    //This prints 'undefined' because 'getRandomQuote' isn't finished yet

    res.render('home', { quote })
})
</code>```

The only way I figured out to do it is as follows, but I find this really messy.
Is there a cleaner way to do this? Or do I always need to put all the lines of code that I want to wait for each other in an async function?

```<code>async function getRandomQuote() {
    try {
        const res = await axios.get("https://api.quotable.io/random?tags=famous-quotes")
        console.log(`${res.data.content} - ${res.data.author}`)     //This prints fine
        return res.data
    } catch(e) {
        console.log('error', e)
    }
}

app.get('/', (req, res) => {

    const getQuoteAndRender = async() => {
        const quote = await getRandomQuote()
        console.log(`${quote.content} - ${quote.author}`)    //This prints only if I wrap everything in yet another aync function, otherwise it will not wait for 'getRandomQuote' to complete

        res.render('home', { quote })
    }
    getQuoteAndRender()
})
</code>```

(Note: I realize rendering the page after I successfully get a quote is not ideal either because this means I will not get a page at all if the quote api (for some reason) doesn't work. But for now I just want to know how to do this with the waiting.)

答:
Heres what you need to do. Make your controller async by doing this app.get('/', async (req, res)

```<code>app.get('/', async (req, res) => {

const quote = await getRandomQuote()
console.log(`${quote.content} - ${quote.author}`)    //This prints 'undefined' because 'getRandomQuote' isn't finished yet

res.render('home', { quote })
})
</code>```

Body:
First I fetch a random quote from a public api. Only AFTER I actually have a quote I want to render the page including that quote.

I am a JavaScript newbie so please bear with me if this is a stupid question.

I was struggling with waiting for the api call to return BEFORE continuing with rendering the page.
I wanted to do the following, but this doesn't work because res.render will be called before I have a quote. (note: I am using Express and Axios)

async function getRandomQuote() {
    try {
        const res = await axios.get("https://api.quotable.io/random?tags=famous-quotes")
        console.log(`${res.data.content} - ${res.data.author}`)     //This prints fine
        return res.data
    } catch(e) {
        console.log('error', e)
    }
}

app.get('/', (req, res) => {

    const quote = getRandomQuote()
    console.log(`${quote.content} - ${quote.author}`)    //This prints 'undefined' because 'getRandomQuote' isn't finished yet

    res.render('home', { quote })
})

The only way I figured out to do it is as follows, but I find this really messy.
Is there a cleaner way to do this? Or do I always need to put all the lines of code that I want to wait for each other in an async function?

async function getRandomQuote() {
    try {
        const res = await axios.get("https://api.quotable.io/random?tags=famous-quotes")
        console.log(`${res.data.content} - ${res.data.author}`)     //This prints fine
        return res.data
    } catch(e) {
        console.log('error', e)
    }
}

app.get('/', (req, res) => {

    const getQuoteAndRender = async() => {
        const quote = await getRandomQuote()
        console.log(`${quote.content} - ${quote.author}`)    //This prints only if I wrap everything in yet another aync function, otherwise it will not wait for 'getRandomQuote' to complete

        res.render('home', { quote })
    }
    getQuoteAndRender()
})

(Note: I realize rendering the page after I successfully get a quote is not ideal either because this means I will not get a page at all if the quote api (for some reason) doesn't work. But for now I just want to know how to do this with the waiting.)

Body:
Heres what you need to do. Make your controller async by doing this app.get('/', async (req, res)

app.get('/', async (req, res) => {

const quote = await getRandomQuote()
console.log(`${quote.content} - ${quote.author}`)    //This prints 'undefined' because 'getRandomQuote' isn't finished yet

res.render('home', { quote })
})


问:
Golang slice append exception
This is a leet code problem, and when I try to answer with the code blew:

package main

import "fmt"

func main() {
    nums := []int{9, 0, 3, 5, 7}
    fmt.Println(subsets(nums))
}

func subsets(nums []int) [][]int {
    var result [][]int
    result = append(result, []int{})
    for _, v := range(nums) {
        for _, rv := range(result) {
            result = append(result, append(rv, v))
        }
    }
    return result
}
```
<p>Leetcode told me wrong answer:</p>
```Wrong Answer
Details
Input
[9,0,3,5,7]
Output
[[],[9],[0],[9,0],[3],[9,3],[0,3],[9,0,3],[5],[9,5],[0,5],[9,0,5],[3,5],[9,3,5],[0,3,5],[9,0,3,7],[7],[9,7],[0,7],[9,0,7],[3,7],[9,3,7],[0,3,7],[9,0,3,7],[5,7],[9,5,7],[0,5,7],[9,0,5,7],[3,5,7],[9,3,5,7],[0,3,5,7],[9,0,3,7,7]]
Expected
[[],[9],[0],[0,9],[3],[3,9],[0,3],[0,3,9],[5],[5,9],[0,5],[0,5,9],[3,5],[3,5,9],[0,3,5],[0,3,5,9],[7],[7,9],[0,7],[0,7,9],[3,7],[3,7,9],[0,3,7],[0,3,7,9],[5,7],[5,7,9],[0,5,7],[0,5,7,9],[3,5,7],[3,5,7,9],[0,3,5,7],[0,3,5,7,9]]
```
<p>The output slice index 15, it should be [9,0,3,5] like the expected, but the result is [9,0,3,7].
So I try to run this code by go playgroud online,the answer is the same wrong, and then I run this code in goland with debug mode,I find when I make the slice <code>append([9,0,3], 7)</code>, the output slice index 15 change at the same time.</p>
<p>My local go env: go version go1.17.6 windows/amd64</p>
<p>I'm just a beginner to golang, could anyone explain this situation?
Thank you very much.</p>
<p>ps: I try to use blew code to recover same issue, but I failed.</p>
<pre class="lang-golang prettyprint-override"><code>package main

import "fmt"

func main() {
    a := [][]int{{}, {9}, {0}, {9, 0}, {3}, {9, 3}, {0, 3}, {9, 0, 3}, {5}, {9, 5}, {0, 5}, {9, 0, 5}, {3, 5}, {9, 3, 5}, {0, 3, 5}, {9, 0, 3, 5}}
    i := 7
    for _, v := range a {
        // fmt.Println(a)
        a = append(a, append(v, i))
        // fmt.Println(a)
    }
    fmt.Println(a)
}

result:
[[] [9] [0] [9 0] [3] [9 3] [0 3] [9 0 3] [5] [9 5] [0 5] [9 0 5] [3 5] [9 3 5] [0 3 5] [9 0 3 5] [7] [9 7] [0 7] [9 0 7] [3 7] [9 3 7] [0 3 7] [9 0 3 7] [5 7] [9 5 7] [0 5 7] [9 0 5 7] [3 5 7] [9 3 5 7] [0 3 5 7] [9 0 3 5 7]]
</code>```

答:
You are reusing the same backing array in some of your slices, because that's what append does if there's capacity remaining. A simple fix is to replace append(rv, v) with append(append([]int{}, rv...), v), creating an entirely new slice. An alternative is to force the append to allocate a fresh backing array by capping the slice to its current length: append(rv[:len(rv):len(rv)], v).

Playground link with working code: https://go.dev/play/p/Gc-yF5KQOAO

Title: Golang slice append exception

Body:
This is a leet code problem, and when I try to answer with the code blew:

package main

import "fmt"

func main() {
    nums := []int{9, 0, 3, 5, 7}
    fmt.Println(subsets(nums))
}

func subsets(nums []int) [][]int {
    var result [][]int
    result = append(result, []int{})
    for _, v := range(nums) {
        for _, rv := range(result) {
            result = append(result, append(rv, v))
        }
    }
    return result
}

Leetcode told me wrong answer:

Wrong Answer
Details
Input
[9,0,3,5,7]
Output
[[],[9],[0],[9,0],[3],[9,3],[0,3],[9,0,3],[5],[9,5],[0,5],[9,0,5],[3,5],[9,3,5],[0,3,5],[9,0,3,7],[7],[9,7],[0,7],[9,0,7],[3,7],[9,3,7],[0,3,7],[9,0,3,7],[5,7],[9,5,7],[0,5,7],[9,0,5,7],[3,5,7],[9,3,5,7],[0,3,5,7],[9,0,3,7,7]]
Expected
[[],[9],[0],[0,9],[3],[3,9],[0,3],[0,3,9],[5],[5,9],[0,5],[0,5,9],[3,5],[3,5,9],[0,3,5],[0,3,5,9],[7],[7,9],[0,7],[0,7,9],[3,7],[3,7,9],[0,3,7],[0,3,7,9],[5,7],[5,7,9],[0,5,7],[0,5,7,9],[3,5,7],[3,5,7,9],[0,3,5,7],[0,3,5,7,9]]

The output slice index 15, it should be [9,0,3,5] like the expected, but the result is [9,0,3,7].
So I try to run this code by go playgroud online,the answer is the same wrong, and then I run this code in goland with debug mode,I find when I make the slice append([9,0,3], 7), the output slice index 15 change at the same time.

My local go env: go version go1.17.6 windows/amd64

I'm just a beginner to golang, could anyone explain this situation?
Thank you very much.

ps: I try to use blew code to recover same issue, but I failed.

package main

import "fmt"

func main() {
    a := [][]int{{}, {9}, {0}, {9, 0}, {3}, {9, 3}, {0, 3}, {9, 0, 3}, {5}, {9, 5}, {0, 5}, {9, 0, 5}, {3, 5}, {9, 3, 5}, {0, 3, 5}, {9, 0, 3, 5}}
    i := 7
    for _, v := range a {
        // fmt.Println(a)
        a = append(a, append(v, i))
        // fmt.Println(a)
    }
    fmt.Println(a)
}

result:
[[] [9] [0] [9 0] [3] [9 3] [0 3] [9 0 3] [5] [9 5] [0 5] [9 0 5] [3 5] [9 3 5] [0 3 5] [9 0 3 5] [7] [9 7] [0 7] [9 0 7] [3 7] [9 3 7] [0 3 7] [9 0 3 7] [5 7] [9 5 7] [0 5 7] [9 0 5 7] [3 5 7] [9 3 5 7] [0 3 5 7] [9 0 3 5 7]]


问:
How to fix 'no entries found' on server run in Parcel.js
On trying to run the server with 'parcel index.js':

Server running at http://localhost:1234    No entries found.
      at Bundler.bundle (/usr/local/lib/node_modules/parcel-bundler/src/Bundler.js:275:17)

Server is showing a 404 error. I'm having the same problem with all my projects, so I feel like this is a global issue. Everything was working fine on all projects and suddenly this is occurring.

already tried:

uninstalling parcel-bundler and reinstalling (globally + locally)

Thanks!

答:
Try

```<code>npm i @parcel/transformer-sass
</code>```

And update parcel bundler .

```<code>npm i parcel
</code>```

Body:
Try

npm i @parcel/transformer-sass

And update parcel bundler .

npm i parcel


问:
Microsoft Graph API : Is it possible to traverse recursive over Folders
We are converting from mail EWS into Microsoft office 365 Graph API,

I want to flat all my Folder tree into list of flat folders, so each entry in list should contain:

Folder:{parentId, myId} , ...

I saw in beta version there is an option to traverse with :

```<code>https://graph.microsoft.com/beta/me/mailFolders/inbox?$top=50&$expand=childFolders($levels=5)
</code>```

but unfortunately I get only the first Level...

```<code>{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#users('4ed9f9bf-cfea-47de-ba2c-e4323d2dd600')/mailFolders/$entity",
    "id": "AQMkAGM5MDIzODk0LTg2NgBjLTQxN2EtOTNmMC0wYWY4M2VkMTg1MWEALgAAAxfTs4ItP_BBtfaokkhWqiMBAJ1RfNBJd7VOqHUq_F8aPdIAAAIBDQAAAA==",
    "displayName": "Inbox",
    "parentFolderId": "AQMkAGM5MDIzODk0LTg2NgBjLTQxN2EtOTNmMC0wYWY4M2VkMTg1MWEALgAAAxfTs4ItP_BBtfaokkhWqiMBAJ1RfNBJd7VOqHUq_F8aPdIAAAIBCQAAAA==",
    "childFolderCount": 1,
    "unreadItemCount": 307,
    "totalItemCount": 320,
    "wellKnownName": "inbox",
    "childFolders@odata.context": "https://graph.microsoft.com/beta/$metadata#users('4ed9f9bf-cfea-47de-ba2c-e4323d2dd600')/mailFolders('AQMkAGM5MDIzODk0LTg2NgBjLTQxN2EtOTNmMC0wYWY4M2VkMTg1MWEALgAAAxfTs4ItP_BBtfaokkhWqiMBAJ1RfNBJd7VOqHUq_F8aPdIAAAIBDQAAAA%3D%3D')/childFolders",
    "childFolders": [
        {
            "id": "AAMkAGM5MDIzODk0LTg2NmMtNDE3YS05M2YwLTBhZjgzZWQxODUxYQAuAAAAAAAX07OCLT-gQbX2qJJIVqojAQCdUXzQSXe1Tqh1KvhfGj3SAAOojCnvAAA=",
            "displayName": "LEVEL_1",
            "parentFolderId": "AQMkAGM5MDIzODk0LTg2NgBjLTQxN2EtOTNmMC0wYWY4M2VkMTg1MWEALgAAAxfTs4ItP_BBtfaokkhWqiMBAJ1RfNBJd7VOqHUq_F8aPdIAAAIBDQAAAA==",
            "childFolderCount": 1,
            "unreadItemCount": 0,
            "totalItemCount": 0,
            "wellKnownName": null
        }
    ]
}
</code>```

Is there a good API either with O-Data or maybe other traversal algorithm (like in EWS - Deep traversal ) , so I can reduce my rest API calls ...

Thanks =]

答:
I found this answer in a similar post and it is in my opinion the easiest way to retrieve all mail folders and subfolders recursiveley in a flat list.

Yes, you can. Simply use delta query to get all the folders.

Request Example: https://graph.microsoft.com/v1.0/users/[user_id]/mailfolders/delta?$select=displayname You get an array of all the folders, with child folders just after the parent-folder item in the response.

Test:
Go to : https://developer.microsoft.com/en-us/graph/graph-explorer
GET Version: v1.0 URL: https://graph.microsoft.com/v1.0/me/Mailfolders/delta
Run Query

Notice "Internal Screens" and "Project Falcon" folders whose parentFolderId is the ID of "Inbox" are also included in the response.

Body:
We are converting from mail EWS into Microsoft office 365 Graph API,

I want to flat all my Folder tree into list of flat folders, so each entry in list should contain:

Folder:{parentId, myId} , ...

I saw in beta version there is an option to traverse with :

https://graph.microsoft.com/beta/me/mailFolders/inbox?$top=50&$expand=childFolders($levels=5)

but unfortunately I get only the first Level...

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#users('4ed9f9bf-cfea-47de-ba2c-e4323d2dd600')/mailFolders/$entity",
    "id": "AQMkAGM5MDIzODk0LTg2NgBjLTQxN2EtOTNmMC0wYWY4M2VkMTg1MWEALgAAAxfTs4ItP_BBtfaokkhWqiMBAJ1RfNBJd7VOqHUq_F8aPdIAAAIBDQAAAA==",
    "displayName": "Inbox",
    "parentFolderId": "AQMkAGM5MDIzODk0LTg2NgBjLTQxN2EtOTNmMC0wYWY4M2VkMTg1MWEALgAAAxfTs4ItP_BBtfaokkhWqiMBAJ1RfNBJd7VOqHUq_F8aPdIAAAIBCQAAAA==",
    "childFolderCount": 1,
    "unreadItemCount": 307,
    "totalItemCount": 320,
    "wellKnownName": "inbox",
    "childFolders@odata.context": "https://graph.microsoft.com/beta/$metadata#users('4ed9f9bf-cfea-47de-ba2c-e4323d2dd600')/mailFolders('AQMkAGM5MDIzODk0LTg2NgBjLTQxN2EtOTNmMC0wYWY4M2VkMTg1MWEALgAAAxfTs4ItP_BBtfaokkhWqiMBAJ1RfNBJd7VOqHUq_F8aPdIAAAIBDQAAAA%3D%3D')/childFolders",
    "childFolders": [
        {
            "id": "AAMkAGM5MDIzODk0LTg2NmMtNDE3YS05M2YwLTBhZjgzZWQxODUxYQAuAAAAAAAX07OCLT-gQbX2qJJIVqojAQCdUXzQSXe1Tqh1KvhfGj3SAAOojCnvAAA=",
            "displayName": "LEVEL_1",
            "parentFolderId": "AQMkAGM5MDIzODk0LTg2NgBjLTQxN2EtOTNmMC0wYWY4M2VkMTg1MWEALgAAAxfTs4ItP_BBtfaokkhWqiMBAJ1RfNBJd7VOqHUq_F8aPdIAAAIBDQAAAA==",
            "childFolderCount": 1,
            "unreadItemCount": 0,
            "totalItemCount": 0,
            "wellKnownName": null
        }
    ]
}

Is there a good API either with O-Data or maybe other traversal algorithm (like in EWS - Deep traversal ) , so I can reduce my rest API calls ...

Thanks =]


答:
Try this:

getRandomQuote()
.then(quote => {
  console.log(`${quote.content} - ${quote.author}`)
  res.render('home', { quote })
});
```

Title: Clearner way to wait for function to complete before continuing


答:
If there are values in table1 Company column other than 'All' then you need to mention t1.Company='All' in where clause.

```<code>Select t2.CompanyNames, t1.FirstName
from table1 t1 cross join table2 t2
where t1.Company='All';
</code>```

Title: Update old data in oracle

Body:
hi I have old data and I want to recover them .Lets say I have the following tables .

Table1:

Company
FirstName

All
Beornræd

Table2:

CompanyNames

X

Y

Z

I want to map All to all values of the table of company such that I obtain the following result.

Table1: after update

Company
FirstName

X
Beornræd

Y
Beornræd

Z
Beornræd

I there a way to update them using a query and thanks in advance.

Body:
If there are values in table1 Company column other than 'All' then you need to mention t1.Company='All' in where clause.

Select t2.CompanyNames, t1.FirstName
from table1 t1 cross join table2 t2
where t1.Company='All';


问:
Oracle - Rank and transform on columns
I got a sample data as below in this cte_orders. Each row is a order and contains the user_id, zone_code and zone_name.

I need to rank the top 3 zone_code for each user_id, and I need the output be on columns.
Like this

```<code>|user_id |  top1_zone  |  top2_zone  |  top3_zone  |
|--------+-------------+-------------+-------------+
|1000    |  5555-ABCD  |  4567-ZMNY  |  7888-IXPO  |
|--------+-------------+-------------+-------------+
|9999    |  3456-JJKL  |  7688-HBGT  |  5555-ABCD  |
|--------+-------------+-------------+-------------+
</code>```

Here's the SQL with the test data and the query that I'm trying.
The problem with this query is the result is given a row for each position of the rank.

```<code>(
    SELECT 1 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
    SELECT 2 as order_id, '1000' as user_id, '4567' as zone_code, 'ZMNY' as zone_name from dual union all
    SELECT 3 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
    SELECT 4 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
    SELECT 5 as order_id, '1000' as user_id, '5599' as zone_code, 'HZTR' as zone_name from dual union all
    SELECT 6 as order_id, '1000' as user_id, '4567' as zone_code, 'ZMNY' as zone_name from dual union all
    SELECT 7 as order_id, '1000' as user_id, '4567' as zone_code, 'ZMNY' as zone_name from dual union all
    SELECT 8 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
    SELECT 9 as order_id, '1000' as user_id, '1999' as zone_code, 'LNKJ' as zone_name from dual union all
    SELECT 10 as order_id, '1000' as user_id, '5677' as zone_code, 'OPLH' as zone_name from dual union all
    SELECT 11 as order_id, '1000' as user_id, '7888' as zone_code, 'IXPO' as zone_name from dual union all
    SELECT 12 as order_id, '9999' as user_id, '5599' as zone_code, 'HZTR' as zone_name from dual union all
    SELECT 13 as order_id, '9999' as user_id, '3456' as zone_code, 'JJKL' as zone_name from dual union all
    SELECT 14 as order_id, '9999' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
    SELECT 15 as order_id, '9999' as user_id, '3456' as zone_code, 'JJKL' as zone_name from dual union all
    SELECT 16 as order_id, '9999' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
    SELECT 17 as order_id, '9999' as user_id, '7688' as zone_code, 'HBGT' as zone_name from dual union all
    SELECT 17 as order_id, '9999' as user_id, '7688' as zone_code, 'HBGT' as zone_name from dual union all
    SELECT 18 as order_id, '9999' as user_id, '1566' as zone_code, 'LNOI' as zone_name from dual union all
    SELECT 19 as order_id, '9999' as user_id, '3456' as zone_code, 'JJKL' as zone_name from dual union all
    SELECT 20 as order_id, '9999' as user_id, '7654' as zone_code, 'NNJJ' as zone_name from dual union all
    SELECT 21 as order_id, '9999' as user_id, '4433' as zone_code, 'NHJE' as zone_name from dual union all
    SELECT 22 as order_id, '9999' as user_id, '4111' as zone_code, 'ABHJ' as zone_name from dual

)

select
    user_id,
    CASE WHEN rank_zones = 1 then zone_concat end as top1_zone,
    CASE WHEN rank_zones = 2 then zone_concat end as top2_zone,
    CASE WHEN rank_zones = 3 then zone_concat end as top3_zone
    from

(
    select
        user_id,
        zone_code||'-'||zone_name as zone_concat,
        row_number() over (partition by user_id order by count(*) desc) rank_zones
    from cte_orders
    group by
        user_id,
        zone_code||'-'||zone_name

)
where rank_zones <= 3

group by
    user_id,
    CASE WHEN rank_zones = 1 then zone_concat end,
    CASE WHEN rank_zones = 2 then zone_concat end,
    CASE WHEN rank_zones = 3 then zone_concat end
order by user_id;
</code>```

The output that i getting

```<code>|user_id |  top1_zone  |  top2_zone  |  top3_zone  |
|--------+-------------+-------------+-------------+
|1000    |  5555-ABCD  |    (null)   |    (null)   |
|--------+-------------+-------------+-------------+
|1000    |    (null)   |  4567-ZMNY  |    (null)   |
|--------+-------------+-------------+-------------+
|1000    |    (null)   |    (null)   |  7888-IXPO  |
|--------+-------------+-------------+-------------+
|9999    |  3456-JJKL  |    (null)   |    (null)   |
|--------+-------------+-------------+-------------+
|9999    |    (null)   |  7688-HBGT  |    (null)   |
|--------+-------------+-------------+-------------+
|9999    |    (null)   |    (null)   |  5555-ABCD  |
|--------+-------------+-------------+-------------+
</code>```

How can i fix my query to get one row for each user_id without the nulls?

答:
How can i fix my query to get one row for each user_id without the nulls?

With a little  bit of aggregation (and comments, as its consequence).

Sample data:

```<code>SQL> with cte_orders as (
  2      SELECT 1 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
  3      SELECT 2 as order_id, '1000' as user_id, '4567' as zone_code, 'ZMNY' as zone_name from dual union all
  4      SELECT 3 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
  5      SELECT 4 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
  6      SELECT 5 as order_id, '1000' as user_id, '5599' as zone_code, 'HZTR' as zone_name from dual union all
  7      SELECT 6 as order_id, '1000' as user_id, '4567' as zone_code, 'ZMNY' as zone_name from dual union all
  8      SELECT 7 as order_id, '1000' as user_id, '4567' as zone_code, 'ZMNY' as zone_name from dual union all
  9      SELECT 8 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
 10      SELECT 9 as order_id, '1000' as user_id, '1999' as zone_code, 'LNKJ' as zone_name from dual union all
 11      SELECT 10 as order_id, '1000' as user_id, '5677' as zone_code, 'OPLH' as zone_name from dual union all
 12      SELECT 11 as order_id, '1000' as user_id, '7888' as zone_code, 'IXPO' as zone_name from dual union all
 13      SELECT 12 as order_id, '9999' as user_id, '5599' as zone_code, 'HZTR' as zone_name from dual union all
 14      SELECT 13 as order_id, '9999' as user_id, '3456' as zone_code, 'JJKL' as zone_name from dual union all
 15      SELECT 14 as order_id, '9999' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
 16      SELECT 15 as order_id, '9999' as user_id, '3456' as zone_code, 'JJKL' as zone_name from dual union all
 17      SELECT 16 as order_id, '9999' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
 18      SELECT 17 as order_id, '9999' as user_id, '7688' as zone_code, 'HBGT' as zone_name from dual union all
 19      SELECT 17 as order_id, '9999' as user_id, '7688' as zone_code, 'HBGT' as zone_name from dual union all
 20      SELECT 18 as order_id, '9999' as user_id, '1566' as zone_code, 'LNOI' as zone_name from dual union all
 21      SELECT 19 as order_id, '9999' as user_id, '3456' as zone_code, 'JJKL' as zone_name from dual union all
 22      SELECT 20 as order_id, '9999' as user_id, '7654' as zone_code, 'NNJJ' as zone_name from dual union all
 23      SELECT 21 as order_id, '9999' as user_id, '4433' as zone_code, 'NHJE' as zone_name from dual union all
 24      SELECT 22 as order_id, '9999' as user_id, '4111' as zone_code, 'ABHJ' as zone_name from dual
 25  )
</code>```

This is what makes what you ask for (the MAX aggregate function; lines #28 - 30):

```<code> 26  select
 27      user_id,
 28      max(CASE WHEN rank_zones = 1 then zone_concat end) as top1_zone,
 29      max(CASE WHEN rank_zones = 2 then zone_concat end) as top2_zone,
 30      max(CASE WHEN rank_zones = 3 then zone_concat end) as top3_zone
 31      from
 32  (
 33      select
 34          user_id,
 35          zone_code||'-'||zone_name as zone_concat,
 36          row_number() over (partition by user_id order by count(*) desc) rank_zones
 37      from cte_orders
 38      group by
 39          user_id,
 40          zone_code||'-'||zone_name
 41  )
 42  where rank_zones <= 5
</code>```

Comment CASE expressions (lines #45 - 47):

```<code> 43  group by
 44      user_id
 45  --    CASE WHEN rank_zones = 1 then zone_concat end,
 46  --    CASE WHEN rank_zones = 2 then zone_concat end,
 47  --    CASE WHEN rank_zones = 3 then zone_concat end
 48  order by user_id;
</code>```

And the result is then:

```<code>USER TOP1_ZONE TOP2_ZONE TOP3_ZONE
---- --------- --------- ---------
1000 5555-ABCD 4567-ZMNY 5599-HZTR
9999 3456-JJKL 5555-ABCD 7688-HBGT

SQL>
</code>```

Title: Oracle - Rank and transform on columns

Body:
I got a sample data as below in this cte_orders. Each row is a order and contains the user_id, zone_code and zone_name.

I need to rank the top 3 zone_code for each user_id, and I need the output be on columns.
Like this

|user_id |  top1_zone  |  top2_zone  |  top3_zone  |
|--------+-------------+-------------+-------------+
|1000    |  5555-ABCD  |  4567-ZMNY  |  7888-IXPO  |
|--------+-------------+-------------+-------------+
|9999    |  3456-JJKL  |  7688-HBGT  |  5555-ABCD  |
|--------+-------------+-------------+-------------+

Here's the SQL with the test data and the query that I'm trying.
The problem with this query is the result is given a row for each position of the rank.

(
    SELECT 1 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
    SELECT 2 as order_id, '1000' as user_id, '4567' as zone_code, 'ZMNY' as zone_name from dual union all
    SELECT 3 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
    SELECT 4 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
    SELECT 5 as order_id, '1000' as user_id, '5599' as zone_code, 'HZTR' as zone_name from dual union all
    SELECT 6 as order_id, '1000' as user_id, '4567' as zone_code, 'ZMNY' as zone_name from dual union all
    SELECT 7 as order_id, '1000' as user_id, '4567' as zone_code, 'ZMNY' as zone_name from dual union all
    SELECT 8 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
    SELECT 9 as order_id, '1000' as user_id, '1999' as zone_code, 'LNKJ' as zone_name from dual union all
    SELECT 10 as order_id, '1000' as user_id, '5677' as zone_code, 'OPLH' as zone_name from dual union all
    SELECT 11 as order_id, '1000' as user_id, '7888' as zone_code, 'IXPO' as zone_name from dual union all
    SELECT 12 as order_id, '9999' as user_id, '5599' as zone_code, 'HZTR' as zone_name from dual union all
    SELECT 13 as order_id, '9999' as user_id, '3456' as zone_code, 'JJKL' as zone_name from dual union all
    SELECT 14 as order_id, '9999' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
    SELECT 15 as order_id, '9999' as user_id, '3456' as zone_code, 'JJKL' as zone_name from dual union all
    SELECT 16 as order_id, '9999' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
    SELECT 17 as order_id, '9999' as user_id, '7688' as zone_code, 'HBGT' as zone_name from dual union all
    SELECT 17 as order_id, '9999' as user_id, '7688' as zone_code, 'HBGT' as zone_name from dual union all
    SELECT 18 as order_id, '9999' as user_id, '1566' as zone_code, 'LNOI' as zone_name from dual union all
    SELECT 19 as order_id, '9999' as user_id, '3456' as zone_code, 'JJKL' as zone_name from dual union all
    SELECT 20 as order_id, '9999' as user_id, '7654' as zone_code, 'NNJJ' as zone_name from dual union all
    SELECT 21 as order_id, '9999' as user_id, '4433' as zone_code, 'NHJE' as zone_name from dual union all
    SELECT 22 as order_id, '9999' as user_id, '4111' as zone_code, 'ABHJ' as zone_name from dual

)

select
    user_id,
    CASE WHEN rank_zones = 1 then zone_concat end as top1_zone,
    CASE WHEN rank_zones = 2 then zone_concat end as top2_zone,
    CASE WHEN rank_zones = 3 then zone_concat end as top3_zone
    from

(
    select
        user_id,
        zone_code||'-'||zone_name as zone_concat,
        row_number() over (partition by user_id order by count(*) desc) rank_zones
    from cte_orders
    group by
        user_id,
        zone_code||'-'||zone_name

)
where rank_zones <= 3

group by
    user_id,
    CASE WHEN rank_zones = 1 then zone_concat end,
    CASE WHEN rank_zones = 2 then zone_concat end,
    CASE WHEN rank_zones = 3 then zone_concat end
order by user_id;

The output that i getting

|user_id |  top1_zone  |  top2_zone  |  top3_zone  |
|--------+-------------+-------------+-------------+
|1000    |  5555-ABCD  |    (null)   |    (null)   |
|--------+-------------+-------------+-------------+
|1000    |    (null)   |  4567-ZMNY  |    (null)   |
|--------+-------------+-------------+-------------+
|1000    |    (null)   |    (null)   |  7888-IXPO  |
|--------+-------------+-------------+-------------+
|9999    |  3456-JJKL  |    (null)   |    (null)   |
|--------+-------------+-------------+-------------+
|9999    |    (null)   |  7688-HBGT  |    (null)   |
|--------+-------------+-------------+-------------+
|9999    |    (null)   |    (null)   |  5555-ABCD  |
|--------+-------------+-------------+-------------+

How can i fix my query to get one row for each user_id without the nulls?

Body:
How can i fix my query to get one row for each user_id without the nulls?

With a little  bit of aggregation (and comments, as its consequence).

Sample data:

SQL> with cte_orders as (
  2      SELECT 1 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
  3      SELECT 2 as order_id, '1000' as user_id, '4567' as zone_code, 'ZMNY' as zone_name from dual union all
  4      SELECT 3 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
  5      SELECT 4 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
  6      SELECT 5 as order_id, '1000' as user_id, '5599' as zone_code, 'HZTR' as zone_name from dual union all
  7      SELECT 6 as order_id, '1000' as user_id, '4567' as zone_code, 'ZMNY' as zone_name from dual union all
  8      SELECT 7 as order_id, '1000' as user_id, '4567' as zone_code, 'ZMNY' as zone_name from dual union all
  9      SELECT 8 as order_id, '1000' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
 10      SELECT 9 as order_id, '1000' as user_id, '1999' as zone_code, 'LNKJ' as zone_name from dual union all
 11      SELECT 10 as order_id, '1000' as user_id, '5677' as zone_code, 'OPLH' as zone_name from dual union all
 12      SELECT 11 as order_id, '1000' as user_id, '7888' as zone_code, 'IXPO' as zone_name from dual union all
 13      SELECT 12 as order_id, '9999' as user_id, '5599' as zone_code, 'HZTR' as zone_name from dual union all
 14      SELECT 13 as order_id, '9999' as user_id, '3456' as zone_code, 'JJKL' as zone_name from dual union all
 15      SELECT 14 as order_id, '9999' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
 16      SELECT 15 as order_id, '9999' as user_id, '3456' as zone_code, 'JJKL' as zone_name from dual union all
 17      SELECT 16 as order_id, '9999' as user_id, '5555' as zone_code, 'ABCD' as zone_name from dual union all
 18      SELECT 17 as order_id, '9999' as user_id, '7688' as zone_code, 'HBGT' as zone_name from dual union all
 19      SELECT 17 as order_id, '9999' as user_id, '7688' as zone_code, 'HBGT' as zone_name from dual union all
 20      SELECT 18 as order_id, '9999' as user_id, '1566' as zone_code, 'LNOI' as zone_name from dual union all
 21      SELECT 19 as order_id, '9999' as user_id, '3456' as zone_code, 'JJKL' as zone_name from dual union all
 22      SELECT 20 as order_id, '9999' as user_id, '7654' as zone_code, 'NNJJ' as zone_name from dual union all
 23      SELECT 21 as order_id, '9999' as user_id, '4433' as zone_code, 'NHJE' as zone_name from dual union all
 24      SELECT 22 as order_id, '9999' as user_id, '4111' as zone_code, 'ABHJ' as zone_name from dual
 25  )

This is what makes what you ask for (the MAX aggregate function; lines #28 - 30):

 26  select
 27      user_id,
 28      max(CASE WHEN rank_zones = 1 then zone_concat end) as top1_zone,
 29      max(CASE WHEN rank_zones = 2 then zone_concat end) as top2_zone,
 30      max(CASE WHEN rank_zones = 3 then zone_concat end) as top3_zone
 31      from
 32  (
 33      select
 34          user_id,
 35          zone_code||'-'||zone_name as zone_concat,
 36          row_number() over (partition by user_id order by count(*) desc) rank_zones
 37      from cte_orders
 38      group by
 39          user_id,
 40          zone_code||'-'||zone_name
 41  )
 42  where rank_zones <= 5

Comment CASE expressions (lines #45 - 47):

 43  group by
 44      user_id
 45  --    CASE WHEN rank_zones = 1 then zone_concat end,
 46  --    CASE WHEN rank_zones = 2 then zone_concat end,
 47  --    CASE WHEN rank_zones = 3 then zone_concat end
 48  order by user_id;

And the result is then:

USER TOP1_ZONE TOP2_ZONE TOP3_ZONE
---- --------- --------- ---------
1000 5555-ABCD 4567-ZMNY 5599-HZTR
9999 3456-JJKL 5555-ABCD 7688-HBGT

SQL>


问:
How to force open a file in linux as a normal user
"/etc/docker/daemon.json"
"/etc/docker/daemon.json" E212: Can't open file for writing

I’m currently trying to set up a Loki server, Promtail, and Grafana as docker images

I installed all the plugins needed however when I tried editing the docker daemon config file with this command

sudo nano /etc/docker/daemon.json

It does not allow me to write due to permissions so I tried using

sudo vi chmod 666 /etc/docker/daemon.json

but this only creates a new file in my directory called chmod

The docker containers are up but I can't see the Loki metrics on my web browser when I try to use localhost:3100/metrics neither can it can be added as a Datasource

Please can you help?

答:
It should be sudo chmod 666 /etc/docker/daemon.json.

What you are doing is running vi against 3 files, chmod, 666, /etc/docker/daemon.json.

The directory /etc/docker must also exist as a directory, and not as a file.


问:
Expression Engine - Import Member Data, create XML file Parse Error
I am trying to use the the Utilities > Member Import Utility to create an XML file that I can then use to import member data.

I have about seventy members to import. I was able to work through the mapping with what appeared to be a good match, but when I click the button, I get the following error:

Line does not match structure

I am using a .csv file to bring the data and I have selected comma as the deliminator. I can map the fields but when I click Create XML I get the Parse error.

Any suggestions on how to resolve this?

Thanks.

答:
I found the answer. I appears to automatically understand that it is relative. When I simply put the name of the file in it went in with error.

So the correct path is: customer.txt

However, because the username is a number and not alpha numeric it cannot be imported.


问:
Naming convention for pub(crate) constructor
I have a struct with two constructors, one for public usage (pub fn new(...)) and one for internal usage (pub(crate) fn new_internal(...)). NB: I use the term "internal" in analogy to C# internal keyword, I don't know what the equivalent Rust term is. The difference between the two methods is given by a check on a &str parameter to verify if its value is a reserved keyword. This check must only occur in the pub(crate) constructor. My question is just for stylistic purposes: is there any naming convention for internal functions to distinguish them from their public variant? In my specific case, how should I name the internal constructor?

答:
No, AFAIK there are no such conventions.

Generally Rust, due to its strong type system, is among the languages that have lesser need for naming conventions related to types, scope, etc., compared to some other languages.


问:
Invalid base64-encoded string: number of data characters (217) cannot be 1 more than a multiple of 4
I am learning Django and creating a to-do app using the framework. While setting up the Django rest framework API, I got an unusual error. I've been using Django for quite a while, but have never come across this error before. I don't know why this error is getting thrown.

The error occurred the very first time when I executed the command manage.py runserver and navigated to users.

The error is as below:

```<code>Invalid base64-encoded string: number of data characters (217) cannot be 1 more than a multiple of 4
Request Method: GET
Request URL:    http://127.0.0.1:8001/users/
Django Version: 3.1
Exception Type: Error
Exception Value:
Invalid base64-encoded string: number of data characters (217) cannot be 1 more than a multiple of 4
Exception Location: /usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/base64.py, line 87, in b64decode
Python Executable:  /Users/yogendrakumar/PycharmProjects/todo_app/bin/python
Python Version: 3.8.5
Python Path:
['/Users/yogendrakumar/PycharmProjects/todo_app',
 '/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python38.zip',
 '/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8',
 '/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload',
 '/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages']
Server time:    Sat, 29 Aug 2020 12:25:01 +0530
</code>```

views.py:

```<code>from django.contrib.auth.models import User, Group
from rest_framework import viewsets
from rest_framework import permissions
from todo.serializers import UserSerializer, GroupSerializer

class UserViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows users to be viewed or edited.
    """
    queryset = User.objects.all().order_by('-date_joined')
    serializer_class = UserSerializer
    permission_classes = [permissions.IsAuthenticated]

class GroupViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows groups to be viewed or edited.
    """
    queryset = Group.objects.all()
    serializer_class = GroupSerializer
    permission_classes = [permissions.IsAuthenticated]
</code>```

Below is the stack trace/traceback:

```<code>Environment:

Request Method: GET
Request URL: http://127.0.0.1:8001/users/

Django Version: 3.1
Python Version: 3.8.5
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'rest_framework',
 'todo']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback (most recent call last):
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 215, in _get_session
    return self._session_cache

During handling of the above exception ('SessionStore' object has no attribute '_session_cache'), another exception occurred:
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 118, in decode
    return signing.loads(session_data, salt=self.key_salt, serializer=self.serializer)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/core/signing.py", line 135, in loads
    base64d = TimestampSigner(key, salt=salt).unsign(s, max_age=max_age).encode()
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/core/signing.py", line 201, in unsign
    result = super().unsign(value)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/core/signing.py", line 184, in unsign
    raise BadSignature('Signature "%s" does not match' % sig)

During handling of the above exception (Signature "xnqTuv_ylPs2HNImqZUFHZYYDRY5IfETbWXc5_4zbB8" does not match), another exception occurred:
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/core/handlers/base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/viewsets.py", line 114, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/views.py", line 505, in dispatch
    response = self.handle_exception(exc)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/views.py", line 465, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
    raise exc
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/views.py", line 493, in dispatch
    self.initial(request, *args, **kwargs)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/views.py", line 410, in initial
    self.perform_authentication(request)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/views.py", line 324, in perform_authentication
    request.user
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/request.py", line 220, in user
    self._authenticate()
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/request.py", line 373, in _authenticate
    user_auth_tuple = authenticator.authenticate(self)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/authentication.py", line 123, in authenticate
    if not user or not user.is_active:
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/utils/functional.py", line 240, in inner
    self._setup()
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/utils/functional.py", line 376, in _setup
    self._wrapped = self._setupfunc()
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/auth/middleware.py", line 23, in <lambda>
    request.user = SimpleLazyObject(lambda: get_user(request))
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/auth/middleware.py", line 11, in get_user
    request._cached_user = auth.get_user(request)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/auth/__init__.py", line 174, in get_user
    user_id = _get_user_session_key(request)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/auth/__init__.py", line 58, in _get_user_session_key
    return get_user_model()._meta.pk.to_python(request.session[SESSION_KEY])
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 65, in __getitem__
    return self._session[key]
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 220, in _get_session
    self._session_cache = self.load()
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/db.py", line 44, in load
    return self.decode(s.session_data) if s else {}
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 122, in decode
    return self._legacy_decode(session_data)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 126, in _legacy_decode
    encoded_data = base64.b64decode(session_data.encode('ascii'))
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)

Exception Type: Error at /users/
Exception Value: Invalid base64-encoded string: number of data characters (217) cannot be 1 more than a multiple of 4
</code>```

serializers.py:

```<code>from django.contrib.auth.models import User, Group
from rest_framework import serializers

class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ['url', 'username', 'email', 'groups']

class GroupSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Group
        fields = ['url', 'name']
</code>```

答: Clear your browsing history: cookies and other side data Then work</p>

Body:
I am learning Django and creating a to-do app using the framework. While setting up the Django rest framework API, I got an unusual error. I've been using Django for quite a while, but have never come across this error before. I don't know why this error is getting thrown.

The error occurred the very first time when I executed the command manage.py runserver and navigated to users.

The error is as below:

Invalid base64-encoded string: number of data characters (217) cannot be 1 more than a multiple of 4
Request Method: GET
Request URL:    http://127.0.0.1:8001/users/
Django Version: 3.1
Exception Type: Error
Exception Value:
Invalid base64-encoded string: number of data characters (217) cannot be 1 more than a multiple of 4
Exception Location: /usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/base64.py, line 87, in b64decode
Python Executable:  /Users/yogendrakumar/PycharmProjects/todo_app/bin/python
Python Version: 3.8.5
Python Path:
['/Users/yogendrakumar/PycharmProjects/todo_app',
 '/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python38.zip',
 '/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8',
 '/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload',
 '/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages']
Server time:    Sat, 29 Aug 2020 12:25:01 +0530

views.py:

from django.contrib.auth.models import User, Group
from rest_framework import viewsets
from rest_framework import permissions
from todo.serializers import UserSerializer, GroupSerializer

class UserViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows users to be viewed or edited.
    """
    queryset = User.objects.all().order_by('-date_joined')
    serializer_class = UserSerializer
    permission_classes = [permissions.IsAuthenticated]

class GroupViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows groups to be viewed or edited.
    """
    queryset = Group.objects.all()
    serializer_class = GroupSerializer
    permission_classes = [permissions.IsAuthenticated]

Below is the stack trace/traceback:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8001/users/

Django Version: 3.1
Python Version: 3.8.5
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'rest_framework',
 'todo']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback (most recent call last):
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 215, in _get_session
    return self._session_cache

During handling of the above exception ('SessionStore' object has no attribute '_session_cache'), another exception occurred:
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 118, in decode
    return signing.loads(session_data, salt=self.key_salt, serializer=self.serializer)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/core/signing.py", line 135, in loads
    base64d = TimestampSigner(key, salt=salt).unsign(s, max_age=max_age).encode()
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/core/signing.py", line 201, in unsign
    result = super().unsign(value)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/core/signing.py", line 184, in unsign
    raise BadSignature('Signature "%s" does not match' % sig)

During handling of the above exception (Signature "xnqTuv_ylPs2HNImqZUFHZYYDRY5IfETbWXc5_4zbB8" does not match), another exception occurred:
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/core/handlers/base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/viewsets.py", line 114, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/views.py", line 505, in dispatch
    response = self.handle_exception(exc)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/views.py", line 465, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
    raise exc
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/views.py", line 493, in dispatch
    self.initial(request, *args, **kwargs)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/views.py", line 410, in initial
    self.perform_authentication(request)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/views.py", line 324, in perform_authentication
    request.user
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/request.py", line 220, in user
    self._authenticate()
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/request.py", line 373, in _authenticate
    user_auth_tuple = authenticator.authenticate(self)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/rest_framework/authentication.py", line 123, in authenticate
    if not user or not user.is_active:
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/utils/functional.py", line 240, in inner
    self._setup()
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/utils/functional.py", line 376, in _setup
    self._wrapped = self._setupfunc()
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/auth/middleware.py", line 23, in <lambda>
    request.user = SimpleLazyObject(lambda: get_user(request))
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/auth/middleware.py", line 11, in get_user
    request._cached_user = auth.get_user(request)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/auth/__init__.py", line 174, in get_user
    user_id = _get_user_session_key(request)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/auth/__init__.py", line 58, in _get_user_session_key
    return get_user_model()._meta.pk.to_python(request.session[SESSION_KEY])
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 65, in __getitem__
    return self._session[key]
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 220, in _get_session
    self._session_cache = self.load()
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/db.py", line 44, in load
    return self.decode(s.session_data) if s else {}
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 122, in decode
    return self._legacy_decode(session_data)
  File "/Users/yogendrakumar/PycharmProjects/todo_app/lib/python3.8/site-packages/django/contrib/sessions/backends/base.py", line 126, in _legacy_decode
    encoded_data = base64.b64decode(session_data.encode('ascii'))
  File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)

Exception Type: Error at /users/
Exception Value: Invalid base64-encoded string: number of data characters (217) cannot be 1 more than a multiple of 4

serializers.py:

from django.contrib.auth.models import User, Group
from rest_framework import serializers

class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ['url', 'username', 'email', 'groups']

class GroupSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Group
        fields = ['url', 'name']


问:
Can't make pytest dependency work for different modules
Following this answer and the doc, I am trying to make tests depend on each other between files:

test_connectivity.py:

```<code>@pytest.mark.dependency(depends=["test_services_up.py::test_sssss"], scope="session")
def test_aaa():
    assert False

@pytest.mark.dependency(depends=["tests/test_services_up.py::test_sssss"], scope="session")
def test_bbb():
    assert False

@pytest.mark.dependency(depends=["atp/tests/test_services_up.py::test_sssss"], scope="session")
def test_ccc():
    assert False
</code>```

and test_services_up.py:

```<code>@pytest.mark.dependency()
def test_sssss():
    assert True
</code>```

The folder structure:

```<code>    atp
    ----|tests
    --------|test_connectivity.py
    --------|test_services_up.py
</code>```

Output:

```<code>> ssh://me@host:port~/src/uv-fleet-atp/venv/bin/python -u ~/.pycharm_helpers/pycharm/_jb_pytest_runner.py --path ~/src/uv-fleet-atp/atp/tests
============================= test session starts ==============================
collected 4 items

test_connectivity.py::test_aaa SKIPPED (test_aaa depends on test_ser...)
Skipped: test_aaa depends on test_services_up.py::test_sssss

test_connectivity.py::test_bbb SKIPPED (test_bbb depends on tests/te...)
Skipped: test_bbb depends on tests/test_services_up.py::test_sssss

test_connectivity.py::test_ccc SKIPPED (test_ccc depends on atp/test...)
Skipped: test_ccc depends on atp/tests/test_services_up.py::test_sssss

test_services_up.py::test_sssss PASSED

========================= 1 passed, 3 skipped in 0.35s =========================

</code>```

How to not skip dependent tests?

答:
As mentioned in the comments, pytest-dependency does not order tests, it relies on the tests executed in the correct order for dependencies to work. The reasoning behind this is that pytest-dependency is thought to do one thing and one thing only, which is to skip tests depending on the test relationships. Ordering can either be done manually by arranging the tests accordingly (e.g. adapt the names, what most users seem to do), or rely on an ordering plugin. There has been a controversial discussion about this, and certainly not everyone agrees with that philosophy (I tend to agree), but in the end it is the prerogative of the plugin author to decide.

pytest-order works together with pytest-dependency. If it is installed and you run your tests with the option --order-dependencies it will order your tests with dependency markers if needed. As usual, you can instead add the option to pytest.ini:

```<code>[pytest]
; always order tests with dependency markers
addopts = --order-dependencies
</code>```

As for tests that cannot be found, it should issue a respective warning.

Disclaimer:

I'm the maintainer of pytest-order.

Body:
Following this answer and the doc, I am trying to make tests depend on each other between files:

test_connectivity.py:

@pytest.mark.dependency(depends=["test_services_up.py::test_sssss"], scope="session")
def test_aaa():
    assert False

@pytest.mark.dependency(depends=["tests/test_services_up.py::test_sssss"], scope="session")
def test_bbb():
    assert False

@pytest.mark.dependency(depends=["atp/tests/test_services_up.py::test_sssss"], scope="session")
def test_ccc():
    assert False

and test_services_up.py:

@pytest.mark.dependency()
def test_sssss():
    assert True

The folder structure:

    atp
    ----|tests
    --------|test_connectivity.py
    --------|test_services_up.py

Output:

> ssh://me@host:port~/src/uv-fleet-atp/venv/bin/python -u ~/.pycharm_helpers/pycharm/_jb_pytest_runner.py --path ~/src/uv-fleet-atp/atp/tests
============================= test session starts ==============================
collected 4 items

test_connectivity.py::test_aaa SKIPPED (test_aaa depends on test_ser...)
Skipped: test_aaa depends on test_services_up.py::test_sssss

test_connectivity.py::test_bbb SKIPPED (test_bbb depends on tests/te...)
Skipped: test_bbb depends on tests/test_services_up.py::test_sssss

test_connectivity.py::test_ccc SKIPPED (test_ccc depends on atp/test...)
Skipped: test_ccc depends on atp/tests/test_services_up.py::test_sssss

test_services_up.py::test_sssss PASSED

========================= 1 passed, 3 skipped in 0.35s =========================

How to not skip dependent tests?

Body:
As mentioned in the comments, pytest-dependency does not order tests, it relies on the tests executed in the correct order for dependencies to work. The reasoning behind this is that pytest-dependency is thought to do one thing and one thing only, which is to skip tests depending on the test relationships. Ordering can either be done manually by arranging the tests accordingly (e.g. adapt the names, what most users seem to do), or rely on an ordering plugin. There has been a controversial discussion about this, and certainly not everyone agrees with that philosophy (I tend to agree), but in the end it is the prerogative of the plugin author to decide.

pytest-order works together with pytest-dependency. If it is installed and you run your tests with the option --order-dependencies it will order your tests with dependency markers if needed. As usual, you can instead add the option to pytest.ini:

[pytest]
; always order tests with dependency markers
addopts = --order-dependencies

As for tests that cannot be found, it should issue a respective warning.

Disclaimer:

I'm the maintainer of pytest-order.


问:
Issue Removing Anaconda from MacOS
I downloaded Anaconda Navigator to my Mac (macOS Sierra). I am trying to cleanly uninstall Anaconda so that there is no trace of it and so python reverts to how it was out-of-the-box.

I have followed the instructions about Anaconda-Clean at this site: https://docs.continuum.io/anaconda/install#uninstall-anaconda

However, when I type the command python from the terminal, I still see Anaconda's presence:

Ryans-MacBook-Pro:~ ryan$ python
Python 3.5.2 |Anaconda 4.2.0 (x86_64)| (default, Jul  2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

What do I do to clean this up?

Thanks,
Ryan

答: for me anaconda3 was located at /opt/anaconda3 so i did rm -rf /opt/anconda3

Title: Issue Removing Anaconda from MacOS